.vscode
.factorypath
bin
+*~
* DONE document maps
* DONE document length/distance thingy
* TODO debug rotating avatar
-* TODO easter egg for YannT
-meta^5 @YannT :: (a -> b) -> f1 (f2 (f3 a)) -> f1 (f2 (f3 b))
-* TODO messages
-tortue
-by the power of grayskull
+* DONE easter egg for YannT
+* DONE messages
* TODO referee cleanup
* DONE upgrade deps
import java.util.Random;
import java.util.Scanner;
-public class Player2 {
+public class Boss {
+ private final static String[] messages = {
+ "meta⁵ @YannT ∷ (a → b) → f1 (f2 (f3 a)) → f1 (f2 (f3 b))",
+ "By the power of Grayskull!",
+ "tortue",
+ "how is ur csb",
+ "YHBT"
+ };
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
- Random random = new Random(0);
+ Random random = new Random();
int roadLength = in.nextInt();
int initialStones = in.nextInt();
int trollDistance = in.nextInt();
int stones = in.nextInt();
int opponentStones = in.nextInt();
-
- System.out.println(random.nextInt(stones+1));
+
+ if (random.nextInt(30) == 0) {
+ System.out.println(random.nextInt(stones+1) + " " +
+ messages[random.nextInt(messages.length)]);
+ }
+ else {
+ System.out.println(random.nextInt(stones+1));
+ }
}
}
}
+++ /dev/null
-exec yes 1
<span>Change Log</span>
</h2>
<ul>
+ <li>
+ Of course that game needed MSG functionality!
+ </li>
<li>
Enforce the one-stone rule. (that also fixed the legacy
buh—sorry people! I put an easter egg in exchange)
package com.codingame.game;
+import java.util.regex.Pattern;
+import java.util.Scanner;
+import java.util.InputMismatchException;
+import java.util.NoSuchElementException;
+
import com.codingame.gameengine.core.AbstractMultiplayerPlayer;
import com.codingame.gameengine.module.entities.Group;
import com.codingame.gameengine.module.entities.Text;
public class Player extends AbstractMultiplayerPlayer {
Group avatar;
Text stoneCounter;
+ Text message;
Sprite castle;
Text stone;
-
+
+ private String messageString;
+ public String getMessageString() { return messageString; }
private int castlePosition;
- public int getCastlePosition() {
- return castlePosition;
- }
- public void setCastlePosition(int pos) {
- castlePosition = pos;
- }
+ public int getCastlePosition() { return castlePosition; }
+ public void setCastlePosition(int pos) { castlePosition = pos; }
private int stones;
- public int getStones()
- {
- return stones;
- }
+ public int getStones() { return stones; }
public void consumeStones(int n) throws InvalidAction {
if (n > stones) {
throw new InvalidAction("attempted to throw more stones than they had.");
}
private int multiplier;
- public int getMultiplier() {
- return multiplier;
- }
- public void setMultiplier(int m){
- multiplier = m;
- }
+ public int getMultiplier() { return multiplier; }
+ public void setMultiplier(int m){ multiplier = m; }
public void adjustScore(int trollPosition) {
setScore(Math.abs(castlePosition - trollPosition));
return 1;
}
+ static final Pattern rest = Pattern.compile(".*");
+ static final Pattern eol = Pattern.compile("\n");
public int getAction() throws TimeoutException, NumberFormatException {
- return Integer.parseInt(getOutputs().get(0));
+ Scanner s = new Scanner(getOutputs().get(0));
+ messageString = "";
+ try {
+ int st = s.nextInt();
+ s.useDelimiter(eol);
+ if (s.hasNext(rest))
+ messageString = s.next(rest);
+ return st;
+ }
+ catch (InputMismatchException e) { throw new NumberFormatException(); }
+ catch (NoSuchElementException e) { throw new NumberFormatException(); }
}
}
.setFillColor(0x7f3f00)
.setAnchor(0.5);
+ player.message = graphicEntityModule.createText()
+ .setX(p0 ? 15 : 1920-15)
+ .setY(680)
+ .setZIndex(1)
+ .setFontSize(40)
+ .setStrokeColor(0x000000)
+ .setFillColor(0xffbf7f)
+ .setAnchorX(p0 ? 0 : 1)
+ .setAnchorY(1);
+
player.castle = graphicEntityModule.createSprite()
.setImage("castle.png")
.setTint(player.getColorToken())
.setFillColor(0x12322a)
.setAnchor(0.5)
.setAlpha(0);
-
}
}
player.setScore(-1);
endGame();
}
+
+ player.message
+ .setText(player.getMessageString());
+ // .setAnchorX(/*player == p0 ? 0 : */ 1);
+ graphicEntityModule.commitEntityState(0, player.message);
}
if (delta > 0) {
}
private void endGame() {
- gameManager.endGame();
+ if (! gameManager.isGameEnd()) {
+ gameManager.endGame();
- if (p0.getScore() > p1.getScore()) {
- gameManager.addToGameSummary(GameManager.formatSuccessMessage(p0.getNicknameToken() + " wins"));
- destroyPlayer(p1);
- }
- else if (p0.getScore() < p1.getScore()) {
- gameManager.addToGameSummary(GameManager.formatSuccessMessage(p1.getNicknameToken() + " wins"));
- destroyPlayer(p0);
- }
- else if (p0.getScore() < 0) {
- gameManager.addToGameSummary(GameManager.formatErrorMessage("Everybody loses!"));
- destroyPlayer(p0);
- destroyPlayer(p1);
- }
- else {
- gameManager.addToGameSummary("Draw.");
+ if (p0.getScore() > p1.getScore()) {
+ gameManager.addToGameSummary(GameManager.formatSuccessMessage(p0.getNicknameToken() + " wins"));
+ destroyPlayer(p1);
+ }
+ else if (p0.getScore() < p1.getScore()) {
+ gameManager.addToGameSummary(GameManager.formatSuccessMessage(p1.getNicknameToken() + " wins"));
+ destroyPlayer(p0);
+ }
+ else if (p0.getScore() < 0) {
+ gameManager.addToGameSummary(GameManager.formatErrorMessage("Everybody loses!"));
+ destroyPlayer(p0);
+ destroyPlayer(p1);
+ }
+ else {
+ gameManager.addToGameSummary("Draw.");
+ }
}
}
}
import java.util.Scanner;
public class Player2 {
+ private final static String[] messages = {
+ "meta⁵ @YannT ∷ (a → b) → f1 (f2 (f3 a)) → f1 (f2 (f3 b))",
+ "By the power of Grayskull!",
+ "tortue",
+ "how is ur csb",
+ "YHBT"
+ };
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
- Random random = new Random(0);
+ Random random = new Random();
int roadLength = in.nextInt();
int initialStones = in.nextInt();
int trollDistance = in.nextInt();
int stones = in.nextInt();
int opponentStones = in.nextInt();
-
- System.out.println(random.nextInt(stones+1));
+
+ if (random.nextInt(30) == 0) {
+ System.out.println(random.nextInt(stones+1) + " " +
+ messages[random.nextInt(messages.length)]);
+ }
+ else {
+ System.out.println(random.nextInt(stones+1));
+ }
}
}
}