Skip to content

Commit

Permalink
Release 1.0.3.
Browse files Browse the repository at this point in the history
  • Loading branch information
exKAZUu committed Jul 21, 2013
1 parent 6e4a368 commit ef721b8
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 28 deletions.
7 changes: 7 additions & 0 deletions CHANGES.jp.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
CHANGES
========================

- 2013/07/20 Version 1.0.3
- ログファイルを出力しないオプション(-s)を追加
- マップの初期画面とゲーム終了時の画面のみ描画するオプション(-r)を追加
- アプレット終了時にエラーを吐かないように修正
- ターンの最初の状態に戻すresetコマンドを追加
- ドキュメントの加筆・修正

- 2013/07/16 Version 1.0.2
- メッセージ中のプレイヤー番号が0から2であったのを1から3に修正

Expand Down
2 changes: 1 addition & 1 deletion build.sbt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name := "Terraforming"

version := "1.0.2"
version := "1.0.3"

scalaVersion := "2.10.2"

Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

<groupId>net.javachallenge</groupId>
<artifactId>Terraforming</artifactId>
<version>1.0.2</version>
<version>1.0.3</version>
<packaging>jar</packaging>

<name>${project.artifactId}</name>
Expand Down
56 changes: 32 additions & 24 deletions src/main/scala/net/aicomp/terraforming/Main.scala
Original file line number Diff line number Diff line change
Expand Up @@ -70,15 +70,13 @@ object Main {
val FPS = "f"
val CUI_MODE = "c"
val RESULT_MODE = "r"
val SILENT = "s"
val USER_PLAYERS = "u"
val LIGHT_GUI_MODE = "l"
val EXTERNAL_AI_PROGRAM = "a"
val INTERNAL_AI_PROGRAM = "i"
val NOT_SHOWING_LOG = "n"
val calendar = Calendar.getInstance
var logFunction: String => Unit = null

def log(text: String) = logFunction(text)

def main(args: Array[String]) {
val options = buildOptions()
Expand All @@ -88,20 +86,25 @@ object Main {
if (cl.hasOption(HELP)) {
printHelp(options)
} else {
startGame(cl)
try {
startGame(cl)
} catch {
case e: Throwable => {
if (!cl.hasOption(SILENT)) {
val errStream = StreamUtils.openStreamForLogging(calendar, "err")
e.printStackTrace(errStream)
System.err.println("Saved an occuerd error in the file of 'log/err_xxxx.txt'");
}
throw e
}
}
}
} catch {
case e: ParseException => {
System.err.println("Error: " + e.getMessage())
printHelp(options)
System.exit(-1)
}
case e: Throwable => {
val errStream = StreamUtils.openStreamForLogging(calendar, "err")
e.printStackTrace(errStream)
System.err.println("Saved an occuerd error in the file of 'log/err_xxxx.txt'");
throw e
}
}
}

Expand Down Expand Up @@ -138,6 +141,7 @@ object Main {
.addOption(RESULT_MODE, false, "Enable result mode which show only a screen of a result.")
.addOption(LIGHT_GUI_MODE, false, "Enable light and fast GUI mode by reducing rendering frequency.")
.addOption(NOT_SHOWING_LOG, false, "Disable showing logs in the scree.")
.addOption(SILENT, false, "Disable writing log files in the log directory.")
.addOption(userOption)
.addOption(externalAIOption)
.addOption(internalAIOption)
Expand All @@ -155,15 +159,17 @@ object Main {
def startGame(cl: CommandLine) {
val (env, startScene) = initializeEnvironmentAndScenes(cl)

val logStream = StreamUtils.openStreamForLogging(calendar, "log")
if (cl.hasOption(NOT_SHOWING_LOG)) {
AbstractScene.display = logStream.print
} else {
val display = AbstractScene.display
AbstractScene.display = { text =>
logStream.print(text)
logStream.flush()
display(text)
if (!cl.hasOption(SILENT)) {
val logStream = StreamUtils.openStreamForLogging(calendar, "log")
if (cl.hasOption(NOT_SHOWING_LOG)) {
AbstractScene.display = logStream.print
} else {
val display = AbstractScene.display
AbstractScene.display = { text =>
logStream.print(text)
logStream.flush()
display(text)
}
}
}

Expand Down Expand Up @@ -238,10 +244,12 @@ object Main {
}
for (cmd <- externalCmds.take(3 - iPlayers)) {
val com = new ExternalComputerPlayer(cmd.split(" "))
val out = StreamUtils.openStreamForLogging(calendar, "stdout_player" + iPlayers)
val err = StreamUtils.openStreamForLogging(calendar, "stderr_player" + iPlayers)
com.addOuputLogStream(out)
com.addErrorLogStream(err)
if (!cl.hasOption(SILENT)) {
val out = StreamUtils.openStreamForLogging(calendar, "stdout_player" + iPlayers)
val err = StreamUtils.openStreamForLogging(calendar, "stderr_player" + iPlayers)
com.addOuputLogStream(out)
com.addErrorLogStream(err)
}
com.addErrorLogStream(System.err)
startMans += (new AIPlayerStartManipulator(players(iPlayers), com)).limittingTime(10000)
gameMans += new AIPlayerGameManipulator(players(iPlayers), com)
Expand Down Expand Up @@ -285,7 +293,7 @@ object Main {
val logScrollPane = new JScrollPane(logArea)
val commandField = new JTextField()

val ret = builder.setTitle("Terraforming version 1.0.2")
val ret = builder.setTitle("Terraforming version 1.0.3")
.setWindowSize(1024, 740)
.setPanelSize(1024, 495)
.setWindowCreator(new WindowCreator() {
Expand Down
2 changes: 1 addition & 1 deletion src/main/scala/net/aicomp/terraforming/entity/Tile.scala
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package net.aicomp.terraforming.entity

@cloneable class Tile {
class Tile extends Cloneable {
var owner: Option[Player] = None
var robots = 0
var movedRobots = 0
Expand Down
2 changes: 1 addition & 1 deletion src/test/java/net/aicomp/terraforming/MainTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public static void before() throws IOException, InterruptedException {
@Test
public void runThreeSampleJavaAIPrograms() {
String command = "java -cp SampleAI/Java Main";
Main.main(new String[] { "-r", "-a", command, command, command });
Main.main(new String[] { "-c", "-a", command, command, command });
}

@Test
Expand Down

0 comments on commit ef721b8

Please sign in to comment.