bug fixes, add logic for random bait selection
This commit is contained in:
@@ -100,10 +100,10 @@ AVAILABLE_UPGRADES = [ # (name, bonus_type, bonus_modifier, price)
|
||||
]
|
||||
|
||||
AVAILABLE_BAITS = [ # (name, max_difficulty)
|
||||
("Worms", 30)
|
||||
("Worms", 50)
|
||||
("Worms", 70)
|
||||
("Worms", 100)
|
||||
("Worms", 30),
|
||||
("Prawns", 50),
|
||||
("Tuna", 70),
|
||||
("Bass", 100)
|
||||
|
||||
]
|
||||
|
||||
@@ -124,7 +124,7 @@ def onAppStart(app):
|
||||
app.waterColor = 'midnightBlue'
|
||||
app.grassColor = 'seaGreen'
|
||||
app.waterHeight = app.height // 3
|
||||
app.waterBottom = app.height = app.waterHeight
|
||||
app.waterBottom = app.height - app.waterHeight
|
||||
app.grassHeight = 20
|
||||
app.grassBottom = app.height - app.waterHeight - app.grassHeight
|
||||
|
||||
@@ -155,6 +155,9 @@ def resetFishingState(app):
|
||||
app.skillCheckSpeed = 1
|
||||
app.skillCheckBars = []
|
||||
app.skillCheckFailed = False
|
||||
|
||||
app.hookedFish = None
|
||||
app.fishingTimer = 0
|
||||
pass
|
||||
|
||||
|
||||
@@ -164,7 +167,30 @@ def pickRandomCreature(app):
|
||||
# weighted toward easier creatures, while still giving rarer/harder ones a
|
||||
# real chance (per the spec's "skewed toward easier but still fun" goal).
|
||||
# Returns the chosen creature record (one entry from app.creatures).
|
||||
pass
|
||||
max_difficulty = [bait[1] for bait in AVAILABLE_BAITS if bait[0] == app.save["current_bait"]][0]
|
||||
|
||||
#here we take the root of the difficulty to represent the weight of that fish, this makes higher difficulty fish easier to catch once unlocked
|
||||
k = 0.5
|
||||
#invert the difficulty and add one so it avoids zero
|
||||
possibilities = [(creature["name"], (max_difficulty - creature["difficulty"] + 1) ** k) for creature in app.creatures if creature["difficulty"] <= max_difficulty]
|
||||
total = sum([c[1] for c in possibilities])
|
||||
|
||||
#now pick randomly
|
||||
roll = random.random() * (total - 0.0001) # a value between 0 and total (minus a small amount so we ensure the while loop triggers)
|
||||
|
||||
while roll > 0:
|
||||
possibleCatch = possibilities.pop(0)
|
||||
roll -= possibleCatch[1]
|
||||
|
||||
catch = [c for c in app.creatures if c["name"] == possibleCatch[0]][0]
|
||||
return catch
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
def startSkillCheck(app, creature):
|
||||
@@ -185,7 +211,8 @@ def startSkillCheck(app, creature):
|
||||
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")]))
|
||||
#50 is default length, adjust it proportionally to difficulty, then add upgrade length multipliers. also set to int instead of float
|
||||
newLen = random.randrange(int((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)
|
||||
@@ -197,6 +224,8 @@ def startSkillCheck(app, creature):
|
||||
lastPos = newPos
|
||||
lastLen = newLen
|
||||
|
||||
#speed is set, bars are set, scene is good, should be fine?
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user