Merge branch 'master' of ssh://gitea.calebfontenot.com:25566/CCF_100/NoMoreAcronyms
This commit is contained in:
commit
0c980dc5e7
@ -6,7 +6,7 @@ module.exports = {
|
|||||||
.setDescription('Draws a design in a codeblock')
|
.setDescription('Draws a design in a codeblock')
|
||||||
.addStringOption(option =>
|
.addStringOption(option =>
|
||||||
option.setName('design')
|
option.setName('design')
|
||||||
.setDescription("Pick a design. (number 1-3)")
|
.setDescription("Pick a design. (number 1-4)")
|
||||||
.setRequired(true)
|
.setRequired(true)
|
||||||
)
|
)
|
||||||
.addStringOption(option =>
|
.addStringOption(option =>
|
||||||
@ -17,7 +17,7 @@ module.exports = {
|
|||||||
async execute(interaction, client) {
|
async execute(interaction, client) {
|
||||||
var inputString = interaction.options.getString('string');
|
var inputString = interaction.options.getString('string');
|
||||||
var design = parseInt(interaction.options.getString('design'));
|
var design = parseInt(interaction.options.getString('design'));
|
||||||
if (design < 1 || design > 3) {
|
if (design < 1 || design > 4) {
|
||||||
await interaction.reply('Invalid design choice.');
|
await interaction.reply('Invalid design choice.');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -32,7 +32,8 @@ module.exports = {
|
|||||||
case 3:
|
case 3:
|
||||||
output = design3(inputString);
|
output = design3(inputString);
|
||||||
break;
|
break;
|
||||||
|
case 4:
|
||||||
|
output = design4(inputString);
|
||||||
}
|
}
|
||||||
console.log(codeBlock("", output));
|
console.log(codeBlock("", output));
|
||||||
var testLength = "\n" + 'output length was ' + (output.length) + " characters.";
|
var testLength = "\n" + 'output length was ' + (output.length) + " characters.";
|
||||||
@ -125,4 +126,52 @@ function design3(input) {
|
|||||||
outputString += "\n";
|
outputString += "\n";
|
||||||
}
|
}
|
||||||
return outputString;
|
return outputString;
|
||||||
|
}
|
||||||
|
|
||||||
|
function design4(input) {
|
||||||
|
var outputString = "";
|
||||||
|
var radius = input.length +1;
|
||||||
|
var mid = radius;
|
||||||
|
if (mid % 2 == 1) {
|
||||||
|
var spaceOffset = " ";
|
||||||
|
} else {
|
||||||
|
var spaceOffset = "";
|
||||||
|
}
|
||||||
|
|
||||||
|
// dist represents distance to the center
|
||||||
|
var dist = parseFloat(0);
|
||||||
|
var space = ""
|
||||||
|
for (let i = 0; i < (input.length / 2); ++i) {
|
||||||
|
space += " ";
|
||||||
|
}
|
||||||
|
// for horizontal movement
|
||||||
|
for (var i = 0; i <= 2 * radius; i++) {
|
||||||
|
if (i != mid && j != 0) {
|
||||||
|
// for vertical movement
|
||||||
|
for (var j = 0; j <= 2 * radius; j++) {
|
||||||
|
|
||||||
|
dist = Math.sqrt(
|
||||||
|
(i - radius) * (i - radius) +
|
||||||
|
(j - radius) * (j - radius)
|
||||||
|
);
|
||||||
|
|
||||||
|
// dist should be in the range (radius - 0.5)
|
||||||
|
// and (radius + 0.5) to print stars(*)
|
||||||
|
|
||||||
|
|
||||||
|
if (dist > radius - 0.5 && dist < radius + 0.5) {
|
||||||
|
outputString += "*";
|
||||||
|
} else {
|
||||||
|
outputString += " ";
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
outputString += "*" + space + input + space + spaceOffset + "*";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
outputString += "\n";
|
||||||
|
}
|
||||||
|
return outputString;
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user