HUMAN: continue implementing upgrades

This commit is contained in:
2026-10-07 13:48:05 -04:00
parent 130e62b326
commit 61a6b199f7
2 changed files with 48 additions and 7 deletions
+39 -6
View File
@@ -11,6 +11,8 @@
from cmu_graphics import *
import json
import random
import math
# =============================================================================
@@ -52,9 +54,9 @@ def loadSave(path="save.json"):
# starts cleanly. This is the only place that reads the save file.
defaultState = {
"cash": 0,
"owned_baits": [],
"owned_baits": ["Worms"],
"owned_upgrades": [],
"current_bait": "worm",
"current_bait": "Worms",
"catch_log": []
}
try:
@@ -97,6 +99,14 @@ AVAILABLE_UPGRADES = [ # (name, bonus_type, bonus_modifier, price)
("Galaxy Rod", "count", 3, 40000)
]
AVAILABLE_BAITS = [ # (name, max_difficulty)
("Worms", 30)
("Worms", 50)
("Worms", 70)
("Worms", 100)
]
def onAppStart(app):
# cmu_graphics entry point. Initialize ALL app.* state here:
# - window/layout constants (width, height, dock/water/grass regions)
@@ -127,8 +137,7 @@ def onAppStart(app):
#SKILL CHECK
app.skillCheckAngle = 0
app.skillCheckSpeed = 1
app.skillCheckBars = []
app.skillCheckSpeed = 1
app.skillCheckBars = [] # tuples of (position, length)
app.skillCheckFailed = False
#FISHING
@@ -142,6 +151,10 @@ def resetFishingState(app):
# begin. Clears any active skill-check data, the pending random bite timer,
# and the currently-hooked creature. Called at startup and after each catch
# is resolved/dismissed.
app.skillCheckAngle = 0 #measured in degrees
app.skillCheckSpeed = 1
app.skillCheckBars = []
app.skillCheckFailed = False
pass
@@ -163,10 +176,30 @@ def startSkillCheck(app, creature):
app.scene = "skill-check"
difficulty = creature["difficulty"]
fishingPower = 1 + sum(upgrade[2] for upgrade in AVAILABLE_UPGRADES if (upgrade[0] in app.save["owned_upgrades"] and upgrade[1] == "power"))
fishingPower = 1 + sum([upgrade[2] for upgrade in AVAILABLE_UPGRADES if (upgrade[0] in app.save["owned_upgrades"] and upgrade[1] == "power")])
app.skillCheckSpeed = difficulty / fishingPower
pass
numBars = difficulty // 10 - sum([upgrade[2] for upgrade in AVAILABLE_UPGRADES if (upgrade[0] in app.save["owned_upgrades"] and upgrade[1] == "count")])
numBars = max(numBars, 1)
lastPos = 0
lastLen = 0
while len(app.skillCheckBars) < numBars:
newLen = random.randrange((1 - (difficulty / 100)) * 50 * math.prod([upgrade[2] for upgrade in AVAILABLE_UPGRADES if (upgrade[0] in app.save["owned_upgrades"] and upgrade[1] == "timing")]))
#take the end of the last bar, and add a random amount between 5 degrees
#and the remaining amount to the end divided by the number of bars left
lastEndPos = (lastPos + lastLen)
newPos = lastEndPos + random.randrange(5, (360 - lastEndPos) // (numBars - len(app.skillCheckBars)))
#cap it to ensure we dont go over
newPos = min(newPos, 360-newLen)
#TODO: double check that multiple bars do not overlap
app.skillCheckBars.append((newPos, newLen))
lastPos = newPos
lastLen = newLen
# =============================================================================