13
0

Add AI
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful

Dieser Commit ist enthalten in:
Chaoscaot 2023-04-01 14:16:39 +02:00
Ursprung 429d4eba84
Commit ccdfb40d71
3 geänderte Dateien mit 68 neuen und 1 gelöschten Zeilen

Datei anzeigen

@ -259,4 +259,9 @@ AUTO_CHECKER_RESULT_RECORD=§7Record: §c[{0}, {1}, {2}]
AUTO_CHECKER_RESULT_TOO_MANY_DISPENSER_ITEMS=§7Dispenser: §c[{0}, {1}, {2}]§7, §c{3} §7items, Max: §e{4}
AUTO_CHECKER_RESULT_FORBIDDEN_ITEM_NBT=§7Forbidden Item NBT: [{0}, {1}, {2}] -> §c{3}
AUTO_CHECKER_RESULT_TELEPORT_HERE=§7Teleport to block
AUTO_CHECKER_RESULT_AFTER_DEADLINE=§cThe deadline has expired: {0}
AUTO_CHECKER_RESULT_AFTER_DEADLINE=§cThe deadline has expired: {0}
AI_START=§7The AI is synthesizing a "§e{}§7"... Please wait.
AI_FINISH=§7The AI has finished synthesizing. It can be found in your Clipboard.
AI_ERROR=§cAn error occurred while synthesizing the schematic. Please try again later or look at the current date.
AI_NO_STEAMIES=§cYou have no Steamies. Please buy some Steamies in the shop.

Datei anzeigen

@ -32,5 +32,6 @@ public class SchematicCommandInitializer {
new SavePart().setMessage(SchematicSystem.MESSAGE);
new SearchPart().setMessage(SchematicSystem.MESSAGE);
new ViewPart().setMessage(SchematicSystem.MESSAGE);
new AprilPart().setMessage(SchematicSystem.MESSAGE);
}
}

Datei anzeigen

@ -0,0 +1,61 @@
/*
This file is a part of the SteamWar software.
Copyright (C) 2023 SteamWar.de-Serverteam
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.steamwar.schematicsystem.commands.schematiccommand.parts;
import de.steamwar.command.AbstractSWCommand;
import de.steamwar.command.SWCommand;
import de.steamwar.schematicsystem.SchematicSystem;
import de.steamwar.schematicsystem.commands.schematiccommand.SchematicCommand;
import de.steamwar.sql.SchematicData;
import de.steamwar.sql.SchematicNode;
import de.steamwar.sql.SteamwarUser;
import lombok.SneakyThrows;
import org.bukkit.entity.Player;
import java.util.List;
import java.util.Random;
@AbstractSWCommand.PartOf(SchematicCommand.class)
public class AprilPart extends SWCommand {
private static final Random random = new Random();
public AprilPart() {
super(null);
}
@SneakyThrows
@Register("prompt")
public void prompt(Player player, String... prompt) {
SteamwarUser user = SteamwarUser.get(player.getName());
String message = String.join(" ", prompt);
SchematicSystem.MESSAGE.send("AI_START", player, message);
Thread.sleep(random.nextInt(3000));
int randomInt = random.nextInt(100);
if (randomInt < 33) {
List<SchematicNode> nodes = SchematicNode.getAll(user);
new SchematicData(nodes.get(random.nextInt(nodes.size()))).loadToPlayer(player);
SchematicSystem.MESSAGE.send("AI_FINISH", player);
} else if (randomInt < 66) {
SchematicSystem.MESSAGE.send("AI_NO_STEAMIES", player);
} else {
SchematicSystem.MESSAGE.send("AI_ERROR", player);
}
}
}