0.0.1.0
This commit is contained in:
commit
ff5f37927e
41 files changed
+419
No files matched your search
+20
@@ -0,0 +1,20 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<classpath>
|
||||||
|
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-25">
|
||||||
|
<attributes>
|
||||||
|
<attribute name="module" value="true"/>
|
||||||
|
</attributes>
|
||||||
|
</classpathentry>
|
||||||
|
<classpathentry kind="src" path="src"/>
|
||||||
|
<classpathentry kind="src" path="/O.T.T.K">
|
||||||
|
<attributes>
|
||||||
|
<attribute name="module" value="true"/>
|
||||||
|
</attributes>
|
||||||
|
</classpathentry>
|
||||||
|
<classpathentry kind="lib" path="Libs/OTTK.jar">
|
||||||
|
<attributes>
|
||||||
|
<attribute name="module" value="true"/>
|
||||||
|
</attributes>
|
||||||
|
</classpathentry>
|
||||||
|
<classpathentry kind="output" path="bin"/>
|
||||||
|
</classpath>
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<projectDescription>
|
||||||
|
<name>game_of_life</name>
|
||||||
|
<comment></comment>
|
||||||
|
<projects>
|
||||||
|
</projects>
|
||||||
|
<buildSpec>
|
||||||
|
<buildCommand>
|
||||||
|
<name>org.eclipse.jdt.core.javabuilder</name>
|
||||||
|
<arguments>
|
||||||
|
</arguments>
|
||||||
|
</buildCommand>
|
||||||
|
</buildSpec>
|
||||||
|
<natures>
|
||||||
|
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||||
|
</natures>
|
||||||
|
</projectDescription>
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
eclipse.preferences.version=1
|
||||||
|
encoding/<project>=UTF-8
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
eclipse.preferences.version=1
|
||||||
|
org.eclipse.jdt.core.compiler.codegen.targetPlatform=25
|
||||||
|
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
|
||||||
|
org.eclipse.jdt.core.compiler.compliance=25
|
||||||
|
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
|
||||||
|
org.eclipse.jdt.core.compiler.debug.localVariable=generate
|
||||||
|
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
|
||||||
|
org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled
|
||||||
|
org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning
|
||||||
|
org.eclipse.jdt.core.compiler.release=enabled
|
||||||
|
org.eclipse.jdt.core.compiler.source=25
|
||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,9 @@
|
|||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
module game_of_life {
|
||||||
|
requires O.T.T.K;
|
||||||
|
}
|
||||||
@@ -0,0 +1,46 @@
|
|||||||
|
package org.kotama.game_of_life;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.kotama.OTTK.Out;
|
||||||
|
import org.kotama.game_of_life.commands.*;
|
||||||
|
import org.kotama.game_of_life.libs.Command;
|
||||||
|
import org.kotama.game_of_life.libs.GameState;
|
||||||
|
import org.kotama.game_of_life.libs.Player;
|
||||||
|
import org.kotama.game_of_life.libs.Stat;
|
||||||
|
import org.kotama.game_of_life.parser.Parser;
|
||||||
|
|
||||||
|
public class GameTools {
|
||||||
|
|
||||||
|
public static void Intro()
|
||||||
|
{
|
||||||
|
Out.WriteMachine("[...] Rebienvenue, ma chere ^^\n", 70);
|
||||||
|
Out.WriteMachine("[...] Assis toi je t'en pris...\n", 50);
|
||||||
|
Out.WriteMachine("[...] Tu te rappelle de moi ?\n", 100);
|
||||||
|
Out.WriteMachine("[...] Tu te rappelle de toi ?\n", 200);
|
||||||
|
}
|
||||||
|
public static GameState Init()
|
||||||
|
{
|
||||||
|
GameState gameState = new GameState(new Player());
|
||||||
|
|
||||||
|
for (Stat s : Stat.values())
|
||||||
|
{
|
||||||
|
gameState.Player.stats.put(s, s.begin);
|
||||||
|
}
|
||||||
|
return gameState;
|
||||||
|
}
|
||||||
|
public static Parser InitCommands()
|
||||||
|
{
|
||||||
|
Parser parser = new Parser();
|
||||||
|
List<Command> Commands = new ArrayList<>();
|
||||||
|
Commands.add(new Dice());
|
||||||
|
Commands.add(new PlayerStats());
|
||||||
|
Commands.add(new Hand());
|
||||||
|
Commands.add(new Gamble());
|
||||||
|
|
||||||
|
parser.addCommands(Commands);
|
||||||
|
|
||||||
|
return parser;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,26 @@
|
|||||||
|
package org.kotama.game_of_life;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.kotama.OTTK.*;
|
||||||
|
import org.kotama.game_of_life.libs.*;
|
||||||
|
import org.kotama.game_of_life.parser.*;
|
||||||
|
import org.kotama.game_of_life.commands.*;
|
||||||
|
import org.kotama.game_of_life.cards.*;
|
||||||
|
|
||||||
|
public class Main {
|
||||||
|
public static void main(String[] args)
|
||||||
|
{
|
||||||
|
Player player = new Player();
|
||||||
|
Parser parser = GameTools.InitCommands();
|
||||||
|
GameState gameState = GameTools.Init();
|
||||||
|
gameState.Player.hand.put(new Plush(), 1);
|
||||||
|
gameState.Player.hand.put(new LongDistanceRelationShip(), 1);
|
||||||
|
while(true)
|
||||||
|
{
|
||||||
|
Out.Print("> ");
|
||||||
|
parser.main(In.Readline().split(" "), gameState);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
package org.kotama.game_of_life.calculator;
|
||||||
|
|
||||||
|
import java.util.EnumMap;
|
||||||
|
|
||||||
|
import org.kotama.game_of_life.libs.Card;
|
||||||
|
import org.kotama.game_of_life.libs.Player;
|
||||||
|
import org.kotama.game_of_life.libs.Stat;
|
||||||
|
|
||||||
|
public class StatCalculator {
|
||||||
|
public static EnumMap<Stat, Integer> calculate(Player player)
|
||||||
|
{
|
||||||
|
EnumMap<Stat, Integer> trueStats = new EnumMap<>(Stat.class);
|
||||||
|
|
||||||
|
for (Stat s : Stat.values())
|
||||||
|
{
|
||||||
|
int total = player.stats.get(s);
|
||||||
|
|
||||||
|
for (Card card : player.hand.keySet())
|
||||||
|
{
|
||||||
|
total += card.effects().getOrDefault(s, 0) * player.hand.get(card);
|
||||||
|
}
|
||||||
|
|
||||||
|
total = Math.max(s.min, Math.min(s.max, total));
|
||||||
|
trueStats.put(s, total);
|
||||||
|
}
|
||||||
|
|
||||||
|
return trueStats;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
package org.kotama.game_of_life.cards;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import org.kotama.game_of_life.libs.Card;
|
||||||
|
import org.kotama.game_of_life.libs.Stat;
|
||||||
|
|
||||||
|
public record LongDistanceRelationShip() implements Card {
|
||||||
|
public String name()
|
||||||
|
{
|
||||||
|
return "LongDistanceRelationShip";
|
||||||
|
}
|
||||||
|
public Map<Stat, Integer> effects()
|
||||||
|
{
|
||||||
|
return Map.of(Stat.AFFECTION, -5);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
package org.kotama.game_of_life.cards;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import org.kotama.game_of_life.libs.*;
|
||||||
|
|
||||||
|
public record Plush() implements Card {
|
||||||
|
public String name()
|
||||||
|
{
|
||||||
|
return "plush";
|
||||||
|
}
|
||||||
|
public Map<Stat, Integer> effects()
|
||||||
|
{
|
||||||
|
return Map.of(Stat.AFFECTION, 10);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
package org.kotama.game_of_life.commands;
|
||||||
|
|
||||||
|
import org.kotama.OTTK.Out;
|
||||||
|
import org.kotama.game_of_life.games.*;
|
||||||
|
import org.kotama.game_of_life.libs.Command;
|
||||||
|
import org.kotama.game_of_life.libs.GameState;
|
||||||
|
|
||||||
|
public class Dice implements Command {
|
||||||
|
public String name()
|
||||||
|
{
|
||||||
|
return "dice";
|
||||||
|
}
|
||||||
|
public void parse(String[] args, GameState gameState)
|
||||||
|
{
|
||||||
|
Out.Println(org.kotama.game_of_life.games.Dice.customd(Integer.parseInt(args[1])));
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,30 @@
|
|||||||
|
package org.kotama.game_of_life.commands;
|
||||||
|
|
||||||
|
import org.kotama.OTTK.Out;
|
||||||
|
import org.kotama.game_of_life.games.Dice;
|
||||||
|
import org.kotama.game_of_life.libs.Card;
|
||||||
|
import org.kotama.game_of_life.libs.Command;
|
||||||
|
import org.kotama.game_of_life.libs.GameState;
|
||||||
|
import org.kotama.game_of_life.games.*;
|
||||||
|
|
||||||
|
public class Gamble implements Command {
|
||||||
|
public String name()
|
||||||
|
{
|
||||||
|
return "gamble";
|
||||||
|
}
|
||||||
|
public void parse(String[] args, GameState gameState)
|
||||||
|
{
|
||||||
|
Card found = null;
|
||||||
|
for (Card c : gameState.Player.hand.keySet())
|
||||||
|
{
|
||||||
|
if (c.name().equalsIgnoreCase(args[1]))
|
||||||
|
{
|
||||||
|
found = c;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (found != null)
|
||||||
|
{
|
||||||
|
org.kotama.game_of_life.games.Gamble.card(gameState.Player.hand, found);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
package org.kotama.game_of_life.commands;
|
||||||
|
|
||||||
|
import org.kotama.OTTK.Out;
|
||||||
|
import org.kotama.game_of_life.libs.Card;
|
||||||
|
import org.kotama.game_of_life.libs.Command;
|
||||||
|
import org.kotama.game_of_life.libs.GameState;
|
||||||
|
import org.kotama.game_of_life.libs.Stat;
|
||||||
|
|
||||||
|
public class Hand implements Command {
|
||||||
|
public String name()
|
||||||
|
{
|
||||||
|
return "hand";
|
||||||
|
}
|
||||||
|
public void parse(String[] args, GameState gameState)
|
||||||
|
{
|
||||||
|
Out.Println("----Hand----");
|
||||||
|
for(Card card : gameState.Player.hand.keySet())
|
||||||
|
{
|
||||||
|
Out.Println("| " + card.name() + ": " + gameState.Player.hand.get(card));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,25 @@
|
|||||||
|
package org.kotama.game_of_life.commands;
|
||||||
|
|
||||||
|
import java.util.EnumMap;
|
||||||
|
|
||||||
|
import org.kotama.OTTK.Out;
|
||||||
|
import org.kotama.game_of_life.calculator.StatCalculator;
|
||||||
|
import org.kotama.game_of_life.libs.Command;
|
||||||
|
import org.kotama.game_of_life.libs.GameState;
|
||||||
|
import org.kotama.game_of_life.libs.Stat;
|
||||||
|
|
||||||
|
public class PlayerStats implements Command {
|
||||||
|
public String name()
|
||||||
|
{
|
||||||
|
return "stats";
|
||||||
|
}
|
||||||
|
public void parse(String[] args, GameState gameState)
|
||||||
|
{
|
||||||
|
EnumMap<Stat, Integer> trueStats = StatCalculator.calculate(gameState.Player);
|
||||||
|
Out.Println("----Stats----");
|
||||||
|
for(Stat stat : trueStats.keySet())
|
||||||
|
{
|
||||||
|
Out.Println("| " + stat + ": " + trueStats.get(stat));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
package org.kotama.game_of_life.games;
|
||||||
|
|
||||||
|
import java.util.Random;
|
||||||
|
|
||||||
|
public class Dice {
|
||||||
|
public static int customd(int d)
|
||||||
|
{
|
||||||
|
Random rnd = new Random();
|
||||||
|
return rnd.nextInt(d);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,33 @@
|
|||||||
|
package org.kotama.game_of_life.games;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Random;
|
||||||
|
|
||||||
|
import org.kotama.OTTK.Out;
|
||||||
|
import org.kotama.game_of_life.libs.Card;
|
||||||
|
import org.kotama.game_of_life.libs.Player;
|
||||||
|
|
||||||
|
public class Gamble {
|
||||||
|
public static void card(Map<Card, Integer> hand, Card d)
|
||||||
|
{
|
||||||
|
if (hand.get(d) != 1)
|
||||||
|
{
|
||||||
|
Out.Println("bien essayé... mais tu peux gamble qu'une fois !\n");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Out.WriteMachine("et on lance la piece...\n", 50);
|
||||||
|
Out.WriteMachine(". . .\n", 500);
|
||||||
|
|
||||||
|
if (Dice.customd(2) == 1)
|
||||||
|
{
|
||||||
|
Out.WriteMachine("oh non... vous DOUBLEZ la carte !\n", 50);
|
||||||
|
hand.put(d, 2);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Out.WriteMachine("oh non... vous PERDEZ la carte !\n", 50);
|
||||||
|
hand.remove(d);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
package org.kotama.game_of_life.libs;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
public interface Card {
|
||||||
|
String name();
|
||||||
|
default Map<Stat, Integer> effects() { return Map.of(); }
|
||||||
|
}
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
package org.kotama.game_of_life.libs;
|
||||||
|
|
||||||
|
public interface Command {
|
||||||
|
String name();
|
||||||
|
public void parse(String[] args, GameState gamestate);
|
||||||
|
}
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
package org.kotama.game_of_life.libs;
|
||||||
|
|
||||||
|
public class GameState{
|
||||||
|
public Player Player;
|
||||||
|
|
||||||
|
public GameState(Player player)
|
||||||
|
{
|
||||||
|
Player = player;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
package org.kotama.game_of_life.libs;
|
||||||
|
|
||||||
|
import java.util.EnumMap;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
public class Player {
|
||||||
|
public String Name;
|
||||||
|
public EnumMap<Stat, Integer> stats = new EnumMap<>(Stat.class);
|
||||||
|
public Map<Card, Integer> hand = new HashMap<>();
|
||||||
|
public Map<Card, Integer> pile = new HashMap<>();
|
||||||
|
}
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
package org.kotama.game_of_life.libs;
|
||||||
|
|
||||||
|
public enum Stat {
|
||||||
|
MENTAL(0, 100, 50),
|
||||||
|
ALCOOL(0, 100, 0),
|
||||||
|
STRESS(0, 100, 50),
|
||||||
|
AFFECTION(0,100,50);
|
||||||
|
|
||||||
|
|
||||||
|
public final int min;
|
||||||
|
public final int max;
|
||||||
|
public final int begin;
|
||||||
|
|
||||||
|
Stat(int min, int max, int begin) {
|
||||||
|
this.min = min;
|
||||||
|
this.max = max;
|
||||||
|
this.begin = begin;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,33 @@
|
|||||||
|
package org.kotama.game_of_life.parser;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.kotama.game_of_life.libs.Command;
|
||||||
|
import org.kotama.game_of_life.libs.GameState;
|
||||||
|
|
||||||
|
public class Parser {
|
||||||
|
List<Command> Commands = new ArrayList<>();
|
||||||
|
|
||||||
|
public void addCommands(List<Command> commands)
|
||||||
|
{
|
||||||
|
Commands = commands;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void main(String[] args, GameState gameState)
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
for (Command command : Commands)
|
||||||
|
{
|
||||||
|
if (args[0].equals(command.name()))
|
||||||
|
{
|
||||||
|
command.parse(args, gameState);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch(Exception e)
|
||||||
|
{
|
||||||
|
System.out.println("bro... WTF is it ???");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in new issue
Block a user