Skip to content

Commit

Permalink
Merge branch 'ecs-fx' of github.com:Cardshifter/Cardshifter into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
Zomis committed Sep 18, 2014
2 parents f74f5ff + 73172d5 commit ebc399c
Show file tree
Hide file tree
Showing 9 changed files with 45 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ public class CommandLineOptions {
@Parameter(names = { "--port" }, description = "Port for use with network playing")
private int port = 4242;

@Parameter(names = { "--lua" }, description = "Use old-style Lua scripts to play")
private boolean lua;

public Random getRandom() {
return (seed == null) ? new Random() : new Random(seed);
}
Expand All @@ -32,5 +35,9 @@ public String getHost() {
public int getPort() {
return port;
}

public boolean isLua() {
return lua;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import com.cardshifter.core.actions.TargetAction;
import com.cardshifter.core.actions.UsableAction;

@Deprecated
public class ConsoleController {
private final Game game;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,25 @@

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.net.UnknownHostException;
import java.util.Scanner;

import org.apache.log4j.PropertyConfigurator;

import net.zomis.cardshifter.ecs.main.ConsoleControllerECS;
import net.zomis.cardshifter.ecs.usage.PhrancisGame;

import com.beust.jcommander.JCommander;
import com.beust.jcommander.ParameterException;
import com.cardshifter.core.Game;

public class Main {

public static void main(String[] args) throws UnknownHostException, IOException, InterruptedException {
PropertyConfigurator.configure(Main.class.getResourceAsStream("log4j.properties"));
try (Scanner input = new Scanner(System.in)) {
CommandLineOptions options = new CommandLineOptions();
JCommander jcommander = new JCommander(options);
Expand All @@ -30,13 +37,21 @@ public static void main(String[] args) throws UnknownHostException, IOException,
NetworkConsoleController networkController = new NetworkConsoleController(options.getHost(), options.getPort());
networkController.play(input);
}
else if (options.isLua()) {
startLuaGame(options);
}
else {
InputStream file = options.getScript() == null ? Main.class.getResourceAsStream("/com/cardshifter/mod/start.lua") : new FileInputStream(new File(options.getScript()));
Game game = new Game(file, options.getRandom());
game.getEvents().startGame(game);
new ConsoleController(game).play(input);
new ConsoleControllerECS(PhrancisGame.createGame()).play(input);
}
}
}

@Deprecated
private static void startLuaGame(CommandLineOptions options) throws FileNotFoundException {
InputStream file = options.getScript() == null ? Main.class.getResourceAsStream("/com/cardshifter/mod/start.lua") : new FileInputStream(new File(options.getScript()));
Game game = new Game(file, options.getRandom());
game.getEvents().startGame(game);
new ConsoleController(game).play(new Scanner(System.in));
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
log4j.rootLogger=debug, stdout

log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout

# Pattern to output the caller's file name and line number.
log4j.appender.stdout.layout.ConversionPattern=[%d{ISO8601}] %5p %10c{1} [%10t] (%22F:%3L) - %m%n

# appender-specific settings, to avoid too much loggings in specific appenders.
log4j.appender.stdout.Threshold=INFO
log4j.appender.R.Threshold=WARN

Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import com.cardshifter.core.Card;
import com.cardshifter.core.Game;

@Deprecated
public class CardAction extends UsableAction {
private final Card card;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import com.cardshifter.core.Game;
import com.cardshifter.core.Player;

@Deprecated
public class PlayerAction extends UsableAction {
private final Player player;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import com.cardshifter.core.Game;
import com.cardshifter.core.Targetable;

@Deprecated
public class TargetAction extends UsableAction {
private final Card card;
private final LuaFunction isTargetAllowedFunction;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import com.cardshifter.core.Events;
import com.cardshifter.core.Game;

@Deprecated
public abstract class UsableAction implements Action {
private final String name;
private final LuaFunction isAllowedFunction;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.cardshifter.core;

import static org.junit.Assert.*;

import org.junit.Test;
import org.luaj.vm2.LuaValue;
import org.luaj.vm2.lib.jse.CoerceLuaToJava;
Expand All @@ -9,6 +10,7 @@

public class StartupTest {
@Test
@Deprecated
public void createGameWithDecks() {
Game game = new Game(Game.class.getResourceAsStream("start.lua"));
game.getEvents().startGame(game);
Expand Down

0 comments on commit ebc399c

Please sign in to comment.