This commit is contained in:
Auric Vente 2024-07-24 03:01:56 -06:00
parent 969d8f1a0f
commit 8f89763a46
3 changed files with 65 additions and 45 deletions

View File

@ -65,20 +65,25 @@ class Ant:
return tooltip return tooltip
def get_status(self) -> str: def get_status(self) -> str:
from .game import Method
if (not self.status) and (not self.method): if (not self.status) and (not self.method):
return "No update yet" return "No update yet"
status = self.status status = self.status
if self.method == "triumph": if self.method == Method.triumph:
total = f"({self.triumph} total)" total = f"({self.triumph} total)"
status = f"{Config.triumph_icon} {Config.triumph_message} {total}" status = f"{Config.triumph_icon} {Config.triumph_message} {total}"
elif self.method == "hit":
elif self.method == Method.hit:
total = f"({self.hits} total)" total = f"({self.hits} total)"
status = f"{Config.hit_icon} {Config.hit_message} {total}" status = f"{Config.hit_icon} {Config.hit_message} {total}"
elif self.method == "thinking":
elif self.method == Method.think:
status = f"Thinking about {status}" status = f"Thinking about {status}"
elif self.method == "travel":
elif self.method == Method.travel:
status = f"Traveling to {status}" status = f"Traveling to {status}"
return status return status

View File

@ -24,43 +24,53 @@ from .window import Window
from .settings import Settings from .settings import Settings
class Method:
merge = "merge"
triumph = "triumph"
hit = "hit"
travel = "travel"
think = "think"
words = "words"
@dataclass @dataclass
class Opt: class Opt:
value: int value: int
weight: int weight: int
method: str
class Method: class Opts:
merge = Opt(0, 1) merge = Opt(0, 1, Method.merge)
triumph = Opt(1, 2) triumph = Opt(1, 2, Method.triumph)
hit = Opt(2, 2) hit = Opt(2, 2, Method.hit)
travel = Opt(3, 2) travel = Opt(3, 2, Method.travel)
thinking_1 = Opt(4, 2) think_1 = Opt(4, 2, Method.think)
thinking_2 = Opt(5, 2) think_2 = Opt(5, 2, Method.think)
sentence_1 = Opt(6, 3) words_1 = Opt(6, 3, Method.words)
sentence_2 = Opt(7, 3) words_2 = Opt(7, 3, Method.words)
sentence_3 = Opt(8, 3) words_3 = Opt(8, 3, Method.words)
sentence_4 = Opt(9, 3) words_4 = Opt(9, 3, Method.words)
@staticmethod @staticmethod
def opts_score() -> list[Opt]: def opts_score() -> list[Opt]:
return [Method.triumph, Method.hit] return [Opts.triumph, Opts.hit]
@staticmethod @staticmethod
def opts_travel() -> list[Opt]: def opts_travel() -> list[Opt]:
return [Method.travel] return [Opts.travel]
@staticmethod @staticmethod
def opts_think() -> list[Opt]: def opts_think() -> list[Opt]:
return [Method.thinking_1, Method.thinking_2] return [Opts.think_1, Opts.think_2]
@staticmethod @staticmethod
def opts_words() -> list[Opt]: def opts_words() -> list[Opt]:
return [ return [
Method.sentence_1, Opts.words_1,
Method.sentence_2, Opts.words_2,
Method.sentence_3, Opts.words_3,
Method.sentence_4, Opts.words_4,
] ]
@ -232,16 +242,16 @@ class Game:
opts: list[Opt] = [] opts: list[Opt] = []
if Settings.score_enabled: if Settings.score_enabled:
opts.extend(Method.opts_score()) opts.extend(Opts.opts_score())
if Settings.travel_enabled: if Settings.travel_enabled:
opts.extend(Method.opts_travel()) opts.extend(Opts.opts_travel())
if Settings.think_enabled: if Settings.think_enabled:
opts.extend(Method.opts_think()) opts.extend(Opts.opts_think())
if Settings.words_enabled: if Settings.words_enabled:
opts.extend(Method.opts_words()) opts.extend(Opts.opts_words())
if not opts: if not opts:
return return
@ -254,56 +264,61 @@ class Game:
if Settings.merge: if Settings.merge:
if Game.merge_charge >= Config.merge_goal: if Game.merge_charge >= Config.merge_goal:
opt = Method.merge opt = Opts.merge
values.insert(0, opt.value) values.insert(0, opt.value)
weights.insert(0, opt.weight) weights.insert(0, opt.weight)
value = random.choices(values, weights=weights, k=1)[0] value = random.choices(values, weights=weights, k=1)[0]
if value == Method.merge.value: if value == Opts.merge.value:
if Ants.merge(): if Ants.merge():
Game.merge_charge = 0 Game.merge_charge = 0
return return
value = Method.sentence_4.value value = Opts.words_4.value
status = "" status = ""
method = "normal" method = ""
if value == Method.triumph.value: if value == Opts.triumph.value:
ant.triumph += 1 ant.triumph += 1
method = "triumph" method = Opts.triumph.method
elif value == Method.hit.value: elif value == Opts.hit.value:
ant.hits += 1 ant.hits += 1
method = "hit" method = Opts.hit.method
elif value == Method.travel.value: elif value == Opts.travel.value:
status = Utils.random_country([]) status = Utils.random_country([])
method = "travel" method = Opts.travel.method
elif value == Method.thinking_1.value: elif value == Opts.think_1.value:
status = Utils.random_name([], Ants.get_names()) status = Utils.random_name([], Ants.get_names())
method = "thinking" method = Opts.think_1.method
elif value == Method.thinking_2.value: elif value == Opts.think_2.value:
status = Utils.random_emoji(3) status = Utils.random_emoji(3)
method = "thinking" method = Opts.think_2.method
elif value == Method.sentence_1.value: elif value == Opts.words_1.value:
status = Utils.rand_sentence.simple_sentence() status = Utils.rand_sentence.simple_sentence()
method = Opts.words_1.method
elif value == Method.sentence_2.value: elif value == Opts.words_2.value:
status = Utils.rand_sentence.bare_bone_sentence() status = Utils.rand_sentence.bare_bone_sentence()
method = Opts.words_2.method
elif value == Method.sentence_3.value: elif value == Opts.words_3.value:
status = Utils.rand_sentence.bare_bone_with_adjective() status = Utils.rand_sentence.bare_bone_with_adjective()
method = Opts.words_3.method
elif value >= Method.sentence_4.value: elif value >= Opts.words_4.value:
status = Utils.rand_sentence.sentence() status = Utils.rand_sentence.sentence()
method = Opts.words_4.method
else: else:
status = "???" status = "???"
method = "unknown"
Ants.set_status(ant, status, method) Ants.set_status(ant, status, method)

View File

@ -1,5 +1,5 @@
{ {
"version": "1.5.0", "version": "1.6.0",
"title": "Cromulant", "title": "Cromulant",
"program": "cromulant", "program": "cromulant",
"author": "madprops", "author": "madprops",