+ Highly experimental last message info now saved
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
package commands.dew;
|
||||
|
||||
import commands.dew.core.impl.DewCore;
|
||||
import core.Command;
|
||||
import core.LocStrings;
|
||||
import core.SubCommandFramework;
|
||||
@@ -11,8 +12,10 @@ import dataStructures.KittyUser;
|
||||
import dataStructures.Response;
|
||||
import dataStructures.UserInput;
|
||||
|
||||
public class CommandDew extends Command {
|
||||
|
||||
public class CommandDew extends Command
|
||||
{
|
||||
@SuppressWarnings("unused")
|
||||
public static DewCore core;
|
||||
SubCommandFramework framework = new SubCommandFramework();
|
||||
|
||||
@Override
|
||||
@@ -28,11 +31,14 @@ public class CommandDew extends Command {
|
||||
{
|
||||
super(level, rating);
|
||||
|
||||
core = new DewCore(framework);
|
||||
|
||||
framework.addCommand("luatest", new CommandDewLuaTest(KittyRole.Dev, KittyRating.Safe));
|
||||
framework.addCommand("realm", new CommandDewRealm(KittyRole.Dev, KittyRating.Safe));
|
||||
framework.addCommand("w", new CommandDewInput("w", KittyRole.Dev, KittyRating.Safe));
|
||||
framework.addCommand("a", new CommandDewInput("a", KittyRole.Dev, KittyRating.Safe));
|
||||
framework.addCommand("s", new CommandDewInput("s", KittyRole.Dev, KittyRating.Safe));
|
||||
framework.addCommand("d", new CommandDewInput("d", KittyRole.Dev, KittyRating.Safe));
|
||||
framework.addCommand("capture", new CommandDewCapture(KittyRole.Dev, KittyRating.Safe));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
package commands.dew;
|
||||
|
||||
import commands.dew.adapter.KittyAdapterDewPlayer;
|
||||
import commands.dew.core.impl.DewCore;
|
||||
import core.SubCommand;
|
||||
import core.SubCommandFormattable;
|
||||
import dataStructures.KittyChannel;
|
||||
import dataStructures.KittyGuild;
|
||||
import dataStructures.KittyRating;
|
||||
import dataStructures.KittyRole;
|
||||
import dataStructures.KittyUser;
|
||||
import dataStructures.UserInput;
|
||||
|
||||
public class CommandDewCapture extends SubCommand
|
||||
{
|
||||
public CommandDewCapture(KittyRole roleLevel, KittyRating contentRating)
|
||||
{
|
||||
super(roleLevel, contentRating);
|
||||
}
|
||||
|
||||
@Override
|
||||
public SubCommandFormattable OnRun(KittyGuild guild, KittyChannel channel, KittyUser user, UserInput input)
|
||||
{
|
||||
KittyAdapterDewPlayer player = DewCore.getOrCreate(user);
|
||||
DewCore.playersCaptured.add(player);
|
||||
return null;//new SubCommandFormattable("captured input for " + user.name);
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
package commands.dew;
|
||||
|
||||
import commands.dew.adapter.KittyAdapterDewPlayer;
|
||||
import commands.dew.core.impl.DewCore;
|
||||
import core.SubCommand;
|
||||
import core.SubCommandFormattable;
|
||||
import dataStructures.KittyChannel;
|
||||
@@ -22,7 +23,7 @@ public class CommandDewInput extends SubCommand
|
||||
@Override
|
||||
public SubCommandFormattable OnRun(KittyGuild guild, KittyChannel channel, KittyUser user, UserInput input)
|
||||
{
|
||||
KittyAdapterDewPlayer player = CommandDewRealm.getOrCreate(user);
|
||||
KittyAdapterDewPlayer player = DewCore.getOrCreate(user);
|
||||
|
||||
int x = player.getRealmX();
|
||||
int y = player.getRealmY();
|
||||
@@ -35,6 +36,6 @@ public class CommandDewInput extends SubCommand
|
||||
case "d": player.setRealmPos(x + 1, y); break;
|
||||
}
|
||||
|
||||
return new SubCommandFormattable(CommandDewRealm.drawWorld(player));
|
||||
return new SubCommandFormattable(DewCore.drawWorld(player));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,11 +1,7 @@
|
||||
package commands.dew;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import commands.dew.adapter.KittyAdapterDewPlayer;
|
||||
import commands.dew.core.data.DewMapTile;
|
||||
import commands.dew.core.data.DewRealm;
|
||||
import commands.dew.core.impl.DewCore;
|
||||
import core.SubCommand;
|
||||
import core.SubCommandFormattable;
|
||||
import dataStructures.KittyChannel;
|
||||
@@ -17,100 +13,17 @@ import dataStructures.UserInput;
|
||||
|
||||
public class CommandDewRealm extends SubCommand
|
||||
{
|
||||
// TODO: CHANGE THIS! THIS IS TEMP STATIC, DO NOT CONTINUE TO DO THIS
|
||||
private static DewRealm realm;
|
||||
public static List<KittyAdapterDewPlayer> players;
|
||||
|
||||
public CommandDewRealm(KittyRole roleLevel, KittyRating contentRating)
|
||||
{
|
||||
super(roleLevel, contentRating);
|
||||
|
||||
realm = new DewRealm();
|
||||
players = new ArrayList<KittyAdapterDewPlayer>();
|
||||
|
||||
for(int y = 0; y < realm.map.length; ++y)
|
||||
{
|
||||
for(int x = 0; x < realm.map[y].length; ++x)
|
||||
{
|
||||
realm.map[y][x] = DewMapTile.Grass.getValue();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static KittyAdapterDewPlayer getOrCreate(KittyUser user)
|
||||
{
|
||||
for(KittyAdapterDewPlayer player : players)
|
||||
{
|
||||
if(player.getUniqueID() == user.uniqueID)
|
||||
{
|
||||
return player;
|
||||
}
|
||||
}
|
||||
|
||||
KittyAdapterDewPlayer player = new KittyAdapterDewPlayer(realm, user, 10, 10);
|
||||
players.add(player);
|
||||
return player;
|
||||
}
|
||||
|
||||
public static String drawWorld(KittyAdapterDewPlayer player)
|
||||
{
|
||||
// Build empty world buffer
|
||||
String[][] worldBuffer = new String[realm.map.length][realm.map[0].length];
|
||||
|
||||
// Build world
|
||||
for(int y = 0; y < realm.map.length; ++y)
|
||||
{
|
||||
for(int x = 0; x < realm.map[y].length; ++x)
|
||||
{
|
||||
switch(DewMapTile.values()[realm.map[y][x]])
|
||||
{
|
||||
case Grass:
|
||||
worldBuffer[y][x] = ",";
|
||||
break;
|
||||
|
||||
default:
|
||||
worldBuffer[y][x] = " ";
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Build players
|
||||
for(KittyAdapterDewPlayer p : players)
|
||||
{
|
||||
worldBuffer[p.getRealmY()][p.getRealmX()] = p.getVisual();
|
||||
}
|
||||
|
||||
// Draw world
|
||||
String out = "";
|
||||
out += "**Realm ID - ** `" + realm.id + "`\n";
|
||||
|
||||
for(int y = 0; y < worldBuffer.length; ++y)
|
||||
{
|
||||
out += "`";
|
||||
|
||||
for(int x = 0; x < worldBuffer[y].length; ++x)
|
||||
{
|
||||
out += worldBuffer[y][x];
|
||||
}
|
||||
|
||||
out += "`";
|
||||
out += "\n";
|
||||
}
|
||||
|
||||
out += "**Stats**\n";
|
||||
out += "`Player Name` - `" + player.getName() + "`\n";
|
||||
out += "`Player Icon` - `" + player.getVisual() + "`\n";
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SubCommandFormattable OnRun(KittyGuild guild, KittyChannel channel, KittyUser user, UserInput input)
|
||||
{
|
||||
KittyAdapterDewPlayer player = getOrCreate(user);
|
||||
KittyAdapterDewPlayer player = DewCore.getOrCreate(user);
|
||||
|
||||
String out = drawWorld(player);
|
||||
String out = DewCore.drawWorld(player);
|
||||
|
||||
return new SubCommandFormattable(out);
|
||||
}
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
package commands.dew.core.data;
|
||||
|
||||
import commands.dew.core.api.IDewLuaSerializable;
|
||||
|
||||
public enum DewMapTile
|
||||
{
|
||||
// Assign multiples of 2 for flag purposes
|
||||
|
||||
@@ -1,11 +1,170 @@
|
||||
package commands.dew.core.impl;
|
||||
|
||||
import commands.dew.core.api.IDewPlayer;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import commands.dew.adapter.KittyAdapterDewPlayer;
|
||||
import commands.dew.core.data.DewMapTile;
|
||||
import commands.dew.core.data.DewRealm;
|
||||
import core.SubCommandFormattable;
|
||||
import core.SubCommandFramework;
|
||||
import dataStructures.KittyChannel;
|
||||
import dataStructures.KittyGuild;
|
||||
import dataStructures.KittyUser;
|
||||
import dataStructures.Response;
|
||||
import dataStructures.UserInput;
|
||||
import utils.GlobalLog;
|
||||
import utils.LogFilter;
|
||||
|
||||
public class DewCore
|
||||
{
|
||||
public DewCore(IDewPlayer player)
|
||||
// TODO: Make realm and players both per-realm
|
||||
public static DewRealm realm;
|
||||
public static List<KittyAdapterDewPlayer> players;
|
||||
public static List<KittyAdapterDewPlayer> playersCaptured;
|
||||
private static SubCommandFramework framework;
|
||||
|
||||
public DewCore(SubCommandFramework framework)
|
||||
{
|
||||
DewCore.framework = framework;
|
||||
DewCore.realm = new DewRealm();
|
||||
DewCore.players = new ArrayList<KittyAdapterDewPlayer>();
|
||||
DewCore.playersCaptured = new ArrayList<KittyAdapterDewPlayer>();
|
||||
|
||||
for(int y = 0; y < realm.map.length; ++y)
|
||||
{
|
||||
for(int x = 0; x < realm.map[y].length; ++x)
|
||||
{
|
||||
realm.map[y][x] = DewMapTile.Grass.getValue();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Returns false if not captured, true if captured.
|
||||
public static boolean ProcessIfCaptured(KittyGuild guild, KittyChannel channel, KittyUser user, UserInput baseInput, Response res)
|
||||
{
|
||||
// Search for a captured player.
|
||||
KittyAdapterDewPlayer player = null;
|
||||
for(KittyAdapterDewPlayer p : playersCaptured)
|
||||
{
|
||||
if(p.getUniqueID() == user.uniqueID)
|
||||
{
|
||||
player = p;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// If we didn't find that the person is captured, return false since we don't need to do anything.
|
||||
if(player == null)
|
||||
return false;
|
||||
|
||||
// See if we run anything - also, check to see if we need to exit.
|
||||
boolean didRun = false;
|
||||
try
|
||||
{
|
||||
UserInput toEdit = new UserInput(baseInput);
|
||||
String key = toEdit.message.toLowerCase().trim();
|
||||
toEdit.key = key;
|
||||
toEdit.args = key;
|
||||
switch(key)
|
||||
{
|
||||
case "cap":
|
||||
case "capture":
|
||||
case "uncapture":
|
||||
case "stop":
|
||||
case "quit":
|
||||
case "exit":
|
||||
playersCaptured.remove(player);
|
||||
return false;
|
||||
}
|
||||
|
||||
SubCommandFormattable f = framework.run(guild, channel, user, toEdit);
|
||||
|
||||
if(f != null)
|
||||
{
|
||||
Response.LastSendMessage.editMessage(f.resString).complete();
|
||||
//f.Call(res);
|
||||
didRun = true;
|
||||
}
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
GlobalLog.error(LogFilter.Command, e);
|
||||
}
|
||||
|
||||
if(didRun)
|
||||
{
|
||||
baseInput.deleteOriginInput();
|
||||
}
|
||||
|
||||
return didRun;
|
||||
}
|
||||
|
||||
public static KittyAdapterDewPlayer getOrCreate(KittyUser user)
|
||||
{
|
||||
for(KittyAdapterDewPlayer player : players)
|
||||
{
|
||||
if(player.getUniqueID() == user.uniqueID)
|
||||
{
|
||||
return player;
|
||||
}
|
||||
}
|
||||
|
||||
KittyAdapterDewPlayer player = new KittyAdapterDewPlayer(realm, user, 10, 10);
|
||||
players.add(player);
|
||||
return player;
|
||||
}
|
||||
|
||||
public static String drawWorld(KittyAdapterDewPlayer player)
|
||||
{
|
||||
// Build empty world buffer
|
||||
String[][] worldBuffer = new String[realm.map.length][realm.map[0].length];
|
||||
|
||||
// Build world
|
||||
for(int y = 0; y < realm.map.length; ++y)
|
||||
{
|
||||
for(int x = 0; x < realm.map[y].length; ++x)
|
||||
{
|
||||
switch(DewMapTile.values()[realm.map[y][x]])
|
||||
{
|
||||
case Grass:
|
||||
worldBuffer[y][x] = ",";
|
||||
break;
|
||||
|
||||
default:
|
||||
worldBuffer[y][x] = " ";
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Build players
|
||||
for(KittyAdapterDewPlayer p : players)
|
||||
{
|
||||
worldBuffer[p.getRealmY()][p.getRealmX()] = p.getVisual();
|
||||
}
|
||||
|
||||
// Draw world
|
||||
String out = "";
|
||||
out += "**Realm ID - ** `" + realm.id + "`\n";
|
||||
|
||||
for(int y = 0; y < worldBuffer.length; ++y)
|
||||
{
|
||||
out += "`";
|
||||
|
||||
for(int x = 0; x < worldBuffer[y].length; ++x)
|
||||
{
|
||||
out += worldBuffer[y][x];
|
||||
}
|
||||
|
||||
out += "`";
|
||||
out += "\n";
|
||||
}
|
||||
|
||||
out += "**Stats**\n";
|
||||
out += "`Player Name` - `" + player.getName() + "`\n";
|
||||
out += "`Player Icon` - `" + player.getVisual() + "`\n";
|
||||
|
||||
return out;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package commands.dew.core.impl;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
|
||||
import org.luaj.vm2.Globals;
|
||||
import org.luaj.vm2.LuaValue;
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
package commands.music;
|
||||
|
||||
import com.google.api.services.youtube.YouTube;
|
||||
|
||||
import core.SubCommand;
|
||||
import core.SubCommandFormattable;
|
||||
import dataStructures.KittyChannel;
|
||||
@@ -13,13 +11,11 @@ import dataStructures.UserInput;
|
||||
|
||||
public class SubCommandAddTrack extends SubCommand
|
||||
{
|
||||
|
||||
public SubCommandAddTrack(KittyRole level, KittyRating rating) { super(level, rating); }
|
||||
|
||||
@Override
|
||||
public SubCommandFormattable OnRun(KittyGuild guild, KittyChannel channel, KittyUser user, UserInput input)
|
||||
{
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user