+ Added super basic initial implementaiton of realm visualization and input
This commit is contained in:
@@ -30,5 +30,9 @@ public class CommandDew extends Command {
|
|||||||
|
|
||||||
framework.addCommand("luatest", new CommandDewLuaTest(KittyRole.Dev, KittyRating.Safe));
|
framework.addCommand("luatest", new CommandDewLuaTest(KittyRole.Dev, KittyRating.Safe));
|
||||||
framework.addCommand("realm", new CommandDewRealm(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));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package commands.dew;
|
package commands.dew;
|
||||||
|
|
||||||
|
import commands.dew.adapter.KittyAdapterDewPlayer;
|
||||||
import core.SubCommand;
|
import core.SubCommand;
|
||||||
import core.SubCommandFormattable;
|
import core.SubCommandFormattable;
|
||||||
import dataStructures.KittyChannel;
|
import dataStructures.KittyChannel;
|
||||||
@@ -11,15 +12,29 @@ import dataStructures.UserInput;
|
|||||||
|
|
||||||
public class CommandDewInput extends SubCommand
|
public class CommandDewInput extends SubCommand
|
||||||
{
|
{
|
||||||
public CommandDewInput(KittyRole roleLevel, KittyRating contentRating) {
|
String letter = "";
|
||||||
|
public CommandDewInput(String letter, KittyRole roleLevel, KittyRating contentRating)
|
||||||
|
{
|
||||||
super(roleLevel, contentRating);
|
super(roleLevel, contentRating);
|
||||||
// TODO Auto-generated constructor stub
|
this.letter = letter.toLowerCase();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public SubCommandFormattable OnRun(KittyGuild guild, KittyChannel channel, KittyUser user, UserInput input) {
|
public SubCommandFormattable OnRun(KittyGuild guild, KittyChannel channel, KittyUser user, UserInput input)
|
||||||
// TODO Auto-generated method stub
|
{
|
||||||
return null;
|
KittyAdapterDewPlayer player = CommandDewRealm.getOrCreate(user);
|
||||||
}
|
|
||||||
|
|
||||||
|
int x = player.getRealmX();
|
||||||
|
int y = player.getRealmY();
|
||||||
|
|
||||||
|
switch(letter)
|
||||||
|
{
|
||||||
|
case "w": player.setRealmPos(x, y - 1); break;
|
||||||
|
case "a": player.setRealmPos(x - 1, y); break;
|
||||||
|
case "s": player.setRealmPos(x, y + 1); break;
|
||||||
|
case "d": player.setRealmPos(x + 1, y); break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return new SubCommandFormattable(CommandDewRealm.drawWorld(player));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,9 @@
|
|||||||
package commands.dew;
|
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.DewMapTile;
|
||||||
import commands.dew.core.data.DewRealm;
|
import commands.dew.core.data.DewRealm;
|
||||||
import core.SubCommand;
|
import core.SubCommand;
|
||||||
@@ -13,11 +17,16 @@ import dataStructures.UserInput;
|
|||||||
|
|
||||||
public class CommandDewRealm extends SubCommand
|
public class CommandDewRealm extends SubCommand
|
||||||
{
|
{
|
||||||
DewRealm realm;
|
// 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)
|
public CommandDewRealm(KittyRole roleLevel, KittyRating contentRating)
|
||||||
{
|
{
|
||||||
super(roleLevel, contentRating);
|
super(roleLevel, contentRating);
|
||||||
|
|
||||||
realm = new DewRealm();
|
realm = new DewRealm();
|
||||||
|
players = new ArrayList<KittyAdapterDewPlayer>();
|
||||||
|
|
||||||
for(int y = 0; y < realm.map.length; ++y)
|
for(int y = 0; y < realm.map.length; ++y)
|
||||||
{
|
{
|
||||||
@@ -28,32 +37,81 @@ public class CommandDewRealm extends SubCommand
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
public static KittyAdapterDewPlayer getOrCreate(KittyUser user)
|
||||||
public SubCommandFormattable OnRun(KittyGuild guild, KittyChannel channel, KittyUser user, UserInput input)
|
|
||||||
{
|
{
|
||||||
String out = "";
|
for(KittyAdapterDewPlayer player : players)
|
||||||
out += "**Realm ID:** `" + realm.id + "`\n";
|
|
||||||
|
|
||||||
for(int x = 0; x < realm.map.length; ++x)
|
|
||||||
{
|
{
|
||||||
out += "`";
|
if(player.getUniqueID() == user.uniqueID)
|
||||||
for(int y = 0; y < realm.map[x].length; ++y)
|
|
||||||
{
|
{
|
||||||
switch(DewMapTile.values()[realm.map[x][y]])
|
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:
|
case Grass:
|
||||||
out += ",";
|
worldBuffer[y][x] = ",";
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
worldBuffer[y][x] = " ";
|
||||||
break;
|
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 += "`";
|
||||||
out += "\n";
|
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);
|
||||||
|
|
||||||
|
String out = drawWorld(player);
|
||||||
|
|
||||||
return new SubCommandFormattable(out);
|
return new SubCommandFormattable(out);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,37 +1,71 @@
|
|||||||
package commands.dew.adapter;
|
package commands.dew.adapter;
|
||||||
|
|
||||||
import commands.dew.core.api.IDewPlayer;
|
import commands.dew.core.api.IDewPlayer;
|
||||||
|
import commands.dew.core.data.DewRealm;
|
||||||
|
import dataStructures.KittyUser;
|
||||||
|
|
||||||
public class KittyAdapterDewPlayer implements IDewPlayer
|
public class KittyAdapterDewPlayer implements IDewPlayer
|
||||||
{
|
{
|
||||||
|
private KittyUser user;
|
||||||
|
private String realmID;
|
||||||
|
private int x;
|
||||||
|
private int y;
|
||||||
|
|
||||||
|
public KittyAdapterDewPlayer(DewRealm realm, KittyUser user, int x, int y)
|
||||||
|
{
|
||||||
|
this.user = user;
|
||||||
|
this.realmID = realm.id;
|
||||||
|
this.x = x;
|
||||||
|
this.y = y;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getVisual()
|
||||||
|
{
|
||||||
|
return user.name.length() >= 1 ? user.name.substring(0, 1) : "@";
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isUser(KittyUser user)
|
||||||
|
{
|
||||||
|
return user.uniqueID == user.uniqueID;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setRealmPos(int x, int y)
|
||||||
|
{
|
||||||
|
this.x = x;
|
||||||
|
this.y = y;
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////
|
||||||
|
// Interface requirements //
|
||||||
|
////////////////////////////
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getName() {
|
public String getName()
|
||||||
// TODO Auto-generated method stub
|
{
|
||||||
return null;
|
return user.name;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getUniqueID() {
|
public String getUniqueID()
|
||||||
// TODO Auto-generated method stub
|
{
|
||||||
return null;
|
return user.uniqueID;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getCurrentRealm() {
|
public String getCurrentRealmID()
|
||||||
// TODO Auto-generated method stub
|
{
|
||||||
return "0";
|
return realmID;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getRealmX() {
|
public int getRealmX()
|
||||||
// TODO Auto-generated method stub
|
{
|
||||||
return 0;
|
return x;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getRealmY() {
|
public int getRealmY()
|
||||||
// TODO Auto-generated method stub
|
{
|
||||||
return 0;
|
return y;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ package commands.dew.core.api;
|
|||||||
public interface IDewPlayer extends IDewEntity
|
public interface IDewPlayer extends IDewEntity
|
||||||
{
|
{
|
||||||
public String getName();
|
public String getName();
|
||||||
public String getCurrentRealm();
|
public String getCurrentRealmID();
|
||||||
public int getRealmX();
|
public int getRealmX();
|
||||||
public int getRealmY();
|
public int getRealmY();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user