HUMAN: continue implementing upgrades
This commit is contained in:
@@ -11,6 +11,8 @@
|
|||||||
|
|
||||||
from cmu_graphics import *
|
from cmu_graphics import *
|
||||||
import json
|
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.
|
# starts cleanly. This is the only place that reads the save file.
|
||||||
defaultState = {
|
defaultState = {
|
||||||
"cash": 0,
|
"cash": 0,
|
||||||
"owned_baits": [],
|
"owned_baits": ["Worms"],
|
||||||
"owned_upgrades": [],
|
"owned_upgrades": [],
|
||||||
"current_bait": "worm",
|
"current_bait": "Worms",
|
||||||
"catch_log": []
|
"catch_log": []
|
||||||
}
|
}
|
||||||
try:
|
try:
|
||||||
@@ -97,6 +99,14 @@ AVAILABLE_UPGRADES = [ # (name, bonus_type, bonus_modifier, price)
|
|||||||
("Galaxy Rod", "count", 3, 40000)
|
("Galaxy Rod", "count", 3, 40000)
|
||||||
]
|
]
|
||||||
|
|
||||||
|
AVAILABLE_BAITS = [ # (name, max_difficulty)
|
||||||
|
("Worms", 30)
|
||||||
|
("Worms", 50)
|
||||||
|
("Worms", 70)
|
||||||
|
("Worms", 100)
|
||||||
|
|
||||||
|
]
|
||||||
|
|
||||||
def onAppStart(app):
|
def onAppStart(app):
|
||||||
# cmu_graphics entry point. Initialize ALL app.* state here:
|
# cmu_graphics entry point. Initialize ALL app.* state here:
|
||||||
# - window/layout constants (width, height, dock/water/grass regions)
|
# - window/layout constants (width, height, dock/water/grass regions)
|
||||||
@@ -127,8 +137,7 @@ def onAppStart(app):
|
|||||||
#SKILL CHECK
|
#SKILL CHECK
|
||||||
app.skillCheckAngle = 0
|
app.skillCheckAngle = 0
|
||||||
app.skillCheckSpeed = 1
|
app.skillCheckSpeed = 1
|
||||||
app.skillCheckBars = []
|
app.skillCheckBars = [] # tuples of (position, length)
|
||||||
app.skillCheckSpeed = 1
|
|
||||||
app.skillCheckFailed = False
|
app.skillCheckFailed = False
|
||||||
|
|
||||||
#FISHING
|
#FISHING
|
||||||
@@ -142,6 +151,10 @@ def resetFishingState(app):
|
|||||||
# begin. Clears any active skill-check data, the pending random bite timer,
|
# begin. Clears any active skill-check data, the pending random bite timer,
|
||||||
# and the currently-hooked creature. Called at startup and after each catch
|
# and the currently-hooked creature. Called at startup and after each catch
|
||||||
# is resolved/dismissed.
|
# is resolved/dismissed.
|
||||||
|
app.skillCheckAngle = 0 #measured in degrees
|
||||||
|
app.skillCheckSpeed = 1
|
||||||
|
app.skillCheckBars = []
|
||||||
|
app.skillCheckFailed = False
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
@@ -163,10 +176,30 @@ def startSkillCheck(app, creature):
|
|||||||
app.scene = "skill-check"
|
app.scene = "skill-check"
|
||||||
difficulty = creature["difficulty"]
|
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
|
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
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# =============================================================================
|
# =============================================================================
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
###############################################
|
###############################################
|
||||||
Total Time: 110 minutes
|
Total Time: 150 minutes
|
||||||
###############################################
|
###############################################
|
||||||
|
|
||||||
###############################################
|
###############################################
|
||||||
@@ -33,3 +33,11 @@ End Time: 1:20pm
|
|||||||
Duration: 20 minutes
|
Duration: 20 minutes
|
||||||
Description: adding more upgrades, fixing citations, considering how I actually want game state to progress
|
Description: adding more upgrades, fixing citations, considering how I actually want game state to progress
|
||||||
###############################################
|
###############################################
|
||||||
|
|
||||||
|
###############################################
|
||||||
|
Date: 07-Oct
|
||||||
|
Start Time: 1:30pm
|
||||||
|
End Time: 1:50pm
|
||||||
|
Duration: 20 minutes
|
||||||
|
Description: continuing work with making upgrades take effect for skill checks
|
||||||
|
###############################################
|
||||||
|
|||||||
Reference in New Issue
Block a user