Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -9,8 +9,8 @@ SELF_REVIVE_CHANCE = 0.10 # Chance to self-revive when downed
|
|
9 |
EXTRA_LOST_PLATE_CHANCE = 1.50 # Chance to lose an extra plate from enemy fire
|
10 |
GULAG_WIN_THRESHOLD = 0.35 # In Gulag: outcome <35% = win (return to battle)
|
11 |
GULAG_ELIMINATED_THRESHOLD = 0.65 # In Gulag: outcome >=35% and <65% = eliminated; >=65% = stalemate (lose a plate and try again)
|
12 |
-
NAT_MIN_DEATHS = 13
|
13 |
-
NAT_MAX_DEATHS = 27
|
14 |
# ------------------------------------------------
|
15 |
|
16 |
game_states = {}
|
@@ -73,7 +73,6 @@ def fight():
|
|
73 |
msg += "You're in Gulag! Use !gulag to fight your opponent."
|
74 |
return limit_response(msg)
|
75 |
|
76 |
-
# If no plates, reduce effective bonus.
|
77 |
effective_bonus = state["bonus"] if state["plates"] > 0 else state["bonus"] * 0.7
|
78 |
state["round"] += 1
|
79 |
r = state["round"]
|
@@ -82,7 +81,6 @@ def fight():
|
|
82 |
resp = f"R{r}: "
|
83 |
|
84 |
if event == "fight":
|
85 |
-
# Air Strike branch remains unchanged.
|
86 |
if "Air Strike" in state["equipment"] and random.random() < AIR_STRIKE_CHANCE:
|
87 |
kills = random.randint(2, 3)
|
88 |
state["kills"] += kills
|
@@ -91,17 +89,14 @@ def fight():
|
|
91 |
resp += f"You called in an Air Strike! It obliterated {kills} enemies. "
|
92 |
state["equipment"].remove("Air Strike")
|
93 |
else:
|
94 |
-
# Use a scenario from 1 to 20 to determine the fight outcome.
|
95 |
scenario = random.randint(1,20)
|
96 |
gun_used = random.choice(["M4", "AK-47", "Shotgun", "Sniper", "SMG"])
|
97 |
downed = False
|
98 |
kills = 0
|
99 |
if scenario <= 4:
|
100 |
-
# Favorable outcome (20% chance)
|
101 |
kills = random.randint(1,2)
|
102 |
resp += f"Your precise shot with the {gun_used} downed {kills} foe(s). "
|
103 |
elif scenario <= 12:
|
104 |
-
# Unfavorable outcome (40% chance): you get little or no kills and are downed.
|
105 |
kills = random.randint(0,1)
|
106 |
if kills == 0:
|
107 |
resp += f"Your {gun_used} malfunctioned, leaving you exposed—you were downed! "
|
@@ -109,10 +104,8 @@ def fight():
|
|
109 |
resp += f"Your {gun_used} fired erratically, securing {kills} kill(s) but leaving you vulnerable—you were downed! "
|
110 |
downed = True
|
111 |
else:
|
112 |
-
# Mixed outcome (40% chance): you get a kill counterattack.
|
113 |
kills = random.randint(1,2)
|
114 |
resp += f"In a desperate counterattack with your {gun_used}, you secured {kills} kill(s). "
|
115 |
-
# In final round, force at least one kill if not downed.
|
116 |
if final_round and not downed and kills == 0:
|
117 |
kills = 1
|
118 |
resp += f"Under final round pressure, you managed a desperate 1 kill with your {gun_used}. "
|
@@ -120,43 +113,59 @@ def fight():
|
|
120 |
if kills > 0:
|
121 |
state["players"] = max(state["players"] - kills, 1)
|
122 |
state["ammo"] = max(state["ammo"] - random.randint(5,10), 0)
|
123 |
-
# Chance to lose an extra plate from enemy fire.
|
124 |
if not downed and random.random() < EXTRA_LOST_PLATE_CHANCE:
|
125 |
lost = 1
|
126 |
state["plates"] = max(state["plates"] - lost, 0)
|
127 |
resp += f"Amid the firefight, you lost {lost} plate from enemy fire. "
|
128 |
|
129 |
-
# If downed, attempt self-revive; if that fails, enter Gulag.
|
130 |
if downed:
|
131 |
-
|
132 |
-
|
133 |
-
if
|
134 |
-
|
135 |
-
|
136 |
-
|
|
|
|
|
|
|
|
|
137 |
else:
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
state["gulag_count"] += 1
|
144 |
-
state["in_gulag"] = True
|
145 |
-
state["status"] = "gulag"
|
146 |
-
resp += f"Downed by enemy fire (lost {lost_plate} plate(s))! You've earned a free Gulag chance. Use !gulag."
|
147 |
return limit_response(resp)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
148 |
else:
|
149 |
-
|
150 |
-
|
|
|
151 |
state["gulag_count"] += 1
|
152 |
state["in_gulag"] = True
|
153 |
state["status"] = "gulag"
|
154 |
-
resp += f"Downed
|
155 |
return limit_response(resp)
|
156 |
else:
|
157 |
-
state["
|
158 |
-
|
159 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
160 |
|
161 |
elif event == "loot":
|
162 |
loot = random.choice(["weapon", "ammo", "armor", "plate", "gulag token"])
|
|
|
9 |
EXTRA_LOST_PLATE_CHANCE = 1.50 # Chance to lose an extra plate from enemy fire
|
10 |
GULAG_WIN_THRESHOLD = 0.35 # In Gulag: outcome <35% = win (return to battle)
|
11 |
GULAG_ELIMINATED_THRESHOLD = 0.65 # In Gulag: outcome >=35% and <65% = eliminated; >=65% = stalemate (lose a plate and try again)
|
12 |
+
NAT_MIN_DEATHS = 13 # Minimum natural enemy deaths per round
|
13 |
+
NAT_MAX_DEATHS = 27 # Maximum natural enemy deaths per round
|
14 |
# ------------------------------------------------
|
15 |
|
16 |
game_states = {}
|
|
|
73 |
msg += "You're in Gulag! Use !gulag to fight your opponent."
|
74 |
return limit_response(msg)
|
75 |
|
|
|
76 |
effective_bonus = state["bonus"] if state["plates"] > 0 else state["bonus"] * 0.7
|
77 |
state["round"] += 1
|
78 |
r = state["round"]
|
|
|
81 |
resp = f"R{r}: "
|
82 |
|
83 |
if event == "fight":
|
|
|
84 |
if "Air Strike" in state["equipment"] and random.random() < AIR_STRIKE_CHANCE:
|
85 |
kills = random.randint(2, 3)
|
86 |
state["kills"] += kills
|
|
|
89 |
resp += f"You called in an Air Strike! It obliterated {kills} enemies. "
|
90 |
state["equipment"].remove("Air Strike")
|
91 |
else:
|
|
|
92 |
scenario = random.randint(1,20)
|
93 |
gun_used = random.choice(["M4", "AK-47", "Shotgun", "Sniper", "SMG"])
|
94 |
downed = False
|
95 |
kills = 0
|
96 |
if scenario <= 4:
|
|
|
97 |
kills = random.randint(1,2)
|
98 |
resp += f"Your precise shot with the {gun_used} downed {kills} foe(s). "
|
99 |
elif scenario <= 12:
|
|
|
100 |
kills = random.randint(0,1)
|
101 |
if kills == 0:
|
102 |
resp += f"Your {gun_used} malfunctioned, leaving you exposed—you were downed! "
|
|
|
104 |
resp += f"Your {gun_used} fired erratically, securing {kills} kill(s) but leaving you vulnerable—you were downed! "
|
105 |
downed = True
|
106 |
else:
|
|
|
107 |
kills = random.randint(1,2)
|
108 |
resp += f"In a desperate counterattack with your {gun_used}, you secured {kills} kill(s). "
|
|
|
109 |
if final_round and not downed and kills == 0:
|
110 |
kills = 1
|
111 |
resp += f"Under final round pressure, you managed a desperate 1 kill with your {gun_used}. "
|
|
|
113 |
if kills > 0:
|
114 |
state["players"] = max(state["players"] - kills, 1)
|
115 |
state["ammo"] = max(state["ammo"] - random.randint(5,10), 0)
|
|
|
116 |
if not downed and random.random() < EXTRA_LOST_PLATE_CHANCE:
|
117 |
lost = 1
|
118 |
state["plates"] = max(state["plates"] - lost, 0)
|
119 |
resp += f"Amid the firefight, you lost {lost} plate from enemy fire. "
|
120 |
|
|
|
121 |
if downed:
|
122 |
+
# If players left are 30 or fewer, do NOT allow Gulag—auto-eliminate.
|
123 |
+
if state["players"] <= 30:
|
124 |
+
if random.random() < SELF_REVIVE_CHANCE:
|
125 |
+
state["revives"] += 1
|
126 |
+
if state["plates"] > 0:
|
127 |
+
lost_plate = 1
|
128 |
+
state["plates"] = max(state["plates"] - lost_plate, 0)
|
129 |
+
resp += f"Miraculously, you self-revived (lost {lost_plate} plate). "
|
130 |
+
else:
|
131 |
+
resp += "Miraculously, you self-revived despite having no plates. "
|
132 |
else:
|
133 |
+
lost_plate = random.randint(1,2)
|
134 |
+
state["plates"] = max(state["plates"] - lost_plate, 0)
|
135 |
+
state["status"] = "eliminated"
|
136 |
+
resp += (f"Downed by enemy fire (lost {lost_plate} plate(s))! With only {state['players']} players remaining, "
|
137 |
+
"you were eliminated. Use !start to play again.")
|
|
|
|
|
|
|
|
|
138 |
return limit_response(resp)
|
139 |
+
else:
|
140 |
+
if random.random() < SELF_REVIVE_CHANCE:
|
141 |
+
state["revives"] += 1
|
142 |
+
if state["plates"] > 0:
|
143 |
+
lost_plate = 1
|
144 |
+
state["plates"] = max(state["plates"] - lost_plate, 0)
|
145 |
+
resp += f"Miraculously, you self-revived (lost {lost_plate} plate). "
|
146 |
+
else:
|
147 |
+
resp += "Miraculously, you self-revived despite having no plates. "
|
148 |
else:
|
149 |
+
lost_plate = random.randint(1,2)
|
150 |
+
state["plates"] = max(state["plates"] - lost_plate, 0)
|
151 |
+
if state["gulag_count"] == 0:
|
152 |
state["gulag_count"] += 1
|
153 |
state["in_gulag"] = True
|
154 |
state["status"] = "gulag"
|
155 |
+
resp += f"Downed by enemy fire (lost {lost_plate} plate(s))! You've earned a free Gulag chance. Use !gulag."
|
156 |
return limit_response(resp)
|
157 |
else:
|
158 |
+
if state["gulag_tokens"] > 0:
|
159 |
+
state["gulag_tokens"] -= 1
|
160 |
+
state["gulag_count"] += 1
|
161 |
+
state["in_gulag"] = True
|
162 |
+
state["status"] = "gulag"
|
163 |
+
resp += f"Downed again (lost {lost_plate} plate(s))! You used a Gulag Token for another chance. Use !gulag."
|
164 |
+
return limit_response(resp)
|
165 |
+
else:
|
166 |
+
state["status"] = "eliminated"
|
167 |
+
resp += f"Downed by enemy fire (lost {lost_plate} plate(s))! No Gulag Tokens available. Game over. Final Kills: {state['kills']}. Use !start to play again."
|
168 |
+
return limit_response(resp)
|
169 |
|
170 |
elif event == "loot":
|
171 |
loot = random.choice(["weapon", "ammo", "armor", "plate", "gulag token"])
|