mirror of
https://github.com/magefree/mage.git
synced 2025-12-25 13:02:06 -08:00
skill setting is now used by AIs
This commit is contained in:
parent
33e7569f87
commit
c87328d08e
15 changed files with 52 additions and 52 deletions
|
|
@ -167,7 +167,7 @@ public class ServerImpl extends RemoteServer implements Server {
|
|||
@Override
|
||||
public boolean joinTable(UUID sessionId, UUID roomId, UUID tableId, String name, String playerType, int skill, DeckCardLists deckList) throws MageException, GameException {
|
||||
try {
|
||||
boolean ret = GamesRoomManager.getInstance().getRoom(roomId).joinTable(sessionId, tableId, name, playerType, deckList);
|
||||
boolean ret = GamesRoomManager.getInstance().getRoom(roomId).joinTable(sessionId, tableId, name, playerType, skill, deckList);
|
||||
logger.info("Session " + sessionId + " joined table " + tableId);
|
||||
return ret;
|
||||
}
|
||||
|
|
@ -182,7 +182,7 @@ public class ServerImpl extends RemoteServer implements Server {
|
|||
@Override
|
||||
public boolean joinTournamentTable(UUID sessionId, UUID roomId, UUID tableId, String name, String playerType, int skill) throws MageException, GameException {
|
||||
try {
|
||||
boolean ret = GamesRoomManager.getInstance().getRoom(roomId).joinTournamentTable(sessionId, tableId, name, playerType);
|
||||
boolean ret = GamesRoomManager.getInstance().getRoom(roomId).joinTournamentTable(sessionId, tableId, name, playerType, skill);
|
||||
logger.info("Session " + sessionId + " joined table " + tableId);
|
||||
return ret;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -106,7 +106,7 @@ public class TableController {
|
|||
);
|
||||
}
|
||||
|
||||
public synchronized boolean joinTournament(UUID sessionId, String name, String playerType) throws GameException {
|
||||
public synchronized boolean joinTournament(UUID sessionId, String name, String playerType, int skill) throws GameException {
|
||||
if (table.getState() != TableState.WAITING) {
|
||||
return false;
|
||||
}
|
||||
|
|
@ -114,7 +114,7 @@ public class TableController {
|
|||
if (seat == null) {
|
||||
throw new GameException("No available seats.");
|
||||
}
|
||||
Player player = createPlayer(name, seat.getPlayerType());
|
||||
Player player = createPlayer(name, seat.getPlayerType(), skill);
|
||||
tournament.addPlayer(player, seat.getPlayerType());
|
||||
table.joinTable(player, seat);
|
||||
logger.info("player joined " + player.getId());
|
||||
|
|
@ -126,7 +126,7 @@ public class TableController {
|
|||
return true;
|
||||
}
|
||||
|
||||
public synchronized boolean joinTable(UUID sessionId, String name, String playerType, DeckCardLists deckList) throws GameException {
|
||||
public synchronized boolean joinTable(UUID sessionId, String name, String playerType, int skill, DeckCardLists deckList) throws GameException {
|
||||
if (table.getState() != TableState.WAITING) {
|
||||
return false;
|
||||
}
|
||||
|
|
@ -139,7 +139,7 @@ public class TableController {
|
|||
throw new GameException(name + " has an invalid deck for this format");
|
||||
}
|
||||
|
||||
Player player = createPlayer(name, seat.getPlayerType());
|
||||
Player player = createPlayer(name, seat.getPlayerType(), skill);
|
||||
match.addPlayer(player, deck);
|
||||
table.joinTable(player, seat);
|
||||
logger.info("player joined " + player.getId());
|
||||
|
|
@ -207,13 +207,13 @@ public class TableController {
|
|||
return table.getValidator().validate(deck);
|
||||
}
|
||||
|
||||
private Player createPlayer(String name, String playerType) {
|
||||
private Player createPlayer(String name, String playerType, int skill) {
|
||||
Player player;
|
||||
if (options == null) {
|
||||
player = PlayerFactory.getInstance().createPlayer(playerType, name, RangeOfInfluence.ALL);
|
||||
player = PlayerFactory.getInstance().createPlayer(playerType, name, RangeOfInfluence.ALL, skill);
|
||||
}
|
||||
else {
|
||||
player = PlayerFactory.getInstance().createPlayer(playerType, name, options.getRange());
|
||||
player = PlayerFactory.getInstance().createPlayer(playerType, name, options.getRange(), skill);
|
||||
}
|
||||
logger.info("Player created " + player.getId());
|
||||
return player;
|
||||
|
|
@ -238,7 +238,7 @@ public class TableController {
|
|||
table.initGame();
|
||||
GameOptions options = new GameOptions();
|
||||
options.testMode = true;
|
||||
match.getGame().setGameOptions(options);
|
||||
// match.getGame().setGameOptions(options);
|
||||
GameManager.getInstance().createGameSession(match.getGame(), sessionPlayerMap, table.getId(), null);
|
||||
ChallengeManager.getInstance().prepareChallenge(getPlayerId(), match);
|
||||
SessionManager sessionManager = SessionManager.getInstance();
|
||||
|
|
|
|||
|
|
@ -91,12 +91,12 @@ public class TableManager {
|
|||
return tables.values();
|
||||
}
|
||||
|
||||
public boolean joinTable(UUID sessionId, UUID tableId, String name, String playerType, DeckCardLists deckList) throws GameException {
|
||||
return controllers.get(tableId).joinTable(sessionId, name, playerType, deckList);
|
||||
public boolean joinTable(UUID sessionId, UUID tableId, String name, String playerType, int skill, DeckCardLists deckList) throws GameException {
|
||||
return controllers.get(tableId).joinTable(sessionId, name, playerType, skill, deckList);
|
||||
}
|
||||
|
||||
public boolean joinTournament(UUID sessionId, UUID tableId, String name, String playerType) throws GameException {
|
||||
return controllers.get(tableId).joinTournament(sessionId, name, playerType);
|
||||
public boolean joinTournament(UUID sessionId, UUID tableId, String name, String playerType, int skill) throws GameException {
|
||||
return controllers.get(tableId).joinTournament(sessionId, name, playerType, skill);
|
||||
}
|
||||
|
||||
public boolean submitDeck(UUID sessionId, UUID tableId, DeckCardLists deckList) throws GameException {
|
||||
|
|
|
|||
|
|
@ -44,8 +44,8 @@ import mage.view.TableView;
|
|||
public interface GamesRoom extends Room {
|
||||
|
||||
public List<TableView> getTables();
|
||||
public boolean joinTable(UUID sessionId, UUID tableId, String name, String playerType, DeckCardLists deckList) throws GameException;
|
||||
public boolean joinTournamentTable(UUID sessionId, UUID tableId, String name, String playerType) throws GameException;
|
||||
public boolean joinTable(UUID sessionId, UUID tableId, String name, String playerType, int skill, DeckCardLists deckList) throws GameException;
|
||||
public boolean joinTournamentTable(UUID sessionId, UUID tableId, String name, String playerType, int skill) throws GameException;
|
||||
public TableView createTable(UUID sessionId, MatchOptions options);
|
||||
public TableView createTournamentTable(UUID sessionId, TournamentOptions options);
|
||||
public void removeTable(UUID sessionId, UUID tableId);
|
||||
|
|
|
|||
|
|
@ -63,9 +63,9 @@ public class GamesRoomImpl extends RoomImpl implements GamesRoom, Serializable {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean joinTable(UUID sessionId, UUID tableId, String name, String playerType, DeckCardLists deckList) throws GameException {
|
||||
public boolean joinTable(UUID sessionId, UUID tableId, String name, String playerType, int skill, DeckCardLists deckList) throws GameException {
|
||||
if (tables.containsKey(tableId)) {
|
||||
return TableManager.getInstance().joinTable(sessionId, tableId, name, playerType, deckList);
|
||||
return TableManager.getInstance().joinTable(sessionId, tableId, name, playerType, skill, deckList);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
|
|
@ -79,9 +79,9 @@ public class GamesRoomImpl extends RoomImpl implements GamesRoom, Serializable {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean joinTournamentTable(UUID sessionId, UUID tableId, String name, String playerType) throws GameException {
|
||||
public boolean joinTournamentTable(UUID sessionId, UUID tableId, String name, String playerType, int skill) throws GameException {
|
||||
if (tables.containsKey(tableId)) {
|
||||
return TableManager.getInstance().joinTournament(sessionId, tableId, name, playerType);
|
||||
return TableManager.getInstance().joinTournament(sessionId, tableId, name, playerType, skill);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -53,12 +53,12 @@ public class PlayerFactory {
|
|||
|
||||
private PlayerFactory() {}
|
||||
|
||||
public Player createPlayer(String playerType, String name, RangeOfInfluence range) {
|
||||
public Player createPlayer(String playerType, String name, RangeOfInfluence range, int skill) {
|
||||
Player player;
|
||||
Constructor<?> con;
|
||||
try {
|
||||
con = playerTypes.get(playerType).getConstructor(new Class[]{String.class, RangeOfInfluence.class});
|
||||
player = (Player)con.newInstance(new Object[] {name, range});
|
||||
con = playerTypes.get(playerType).getConstructor(new Class[]{String.class, RangeOfInfluence.class, int.class});
|
||||
player = (Player)con.newInstance(new Object[] {name, range, skill});
|
||||
} catch (Exception ex) {
|
||||
logger.fatal("PlayerFactory error ", ex);
|
||||
return null;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue