Skip to content

Commit

Permalink
Bug fixes
Browse files Browse the repository at this point in the history
- mirrors breaking when you reach a streak of 7
- mirrors streak not returning to 0 after 7 =w=
- mirrors always bumping you to mirror 2 when moving to the next mirror
- mirrors reward screen showing you got the amount of mirrors points
that you actually have
- quests with only one human enemy broke while trying to drop
- buying some items restricted you to only one item
- couldn't move more than one memoria to the vault at a time
  • Loading branch information
kavezo committed Dec 12, 2020
1 parent 5b46965 commit 0329b53
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 21 deletions.
10 changes: 7 additions & 3 deletions api/questEndpoints/get.py
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,9 @@ def dropItems(battleId, waveList):

conditionalRate = min(1, dropRates[dropId]/numDroppers)
for enemyId in enemyIds:
if len(enemyIdxs[enemyId])==0:
continue

numDrops = np.random.binomial(enemyCounts[enemyId], conditionalRate)
idxs = np.random.choice(len(enemyIdxs[enemyId]), numDrops, replace=False)
removeIdxs = []
Expand All @@ -259,6 +262,7 @@ def dropItems(battleId, waveList):
for removeIdx in removeIdxs: enemyIdxs[enemyId].remove(removeIdx)

# handle drops that can be dropped by anyone

for dropItemId, codes in possibleDropCodes.items():
numEnemies = len(availableIdxs)
if numEnemies == 0: continue
Expand All @@ -282,14 +286,12 @@ def dropItems(battleId, waveList):

waveNo, enemyIdx = availableIdxs[availableIdx]
waveList[waveNo]['enemyList'][enemyIdx]['dropItemType'] = rarityBox
promisedDrops[code] = promisedDrops.get(code, 0) + 1
removeIdxs.append((waveNo, enemyIdx))
for removeIdx in removeIdxs: availableIdxs.remove(removeIdx)

# first clear reward
userQuestBattle = dt.getUserObject('userQuestBattleList', battleId)
if 'cleared' not in userQuestBattle or not userQuestBattle['cleared'] and 'firstClearRewardCodes' in battle:
waveNo, enemyIdx = availableIdxs[np.random.choice(len(availableIdxs), 1)[0]]
code = battle['firstClearRewardCodes']
if code.startswith('RICHE'):
rarityBox = 'BOX_BRONZE'
Expand All @@ -300,7 +302,9 @@ def dropItems(battleId, waveList):
giftId = extractGiftCode(code)
rarityBox = 'BOX_'+boxTypes[dt.masterGifts[giftId]['rank']]

waveList[waveNo]['enemyList'][enemyIdx]['dropItemType'] = rarityBox
if len(availableIdxs) != 0:
waveNo, enemyIdx = availableIdxs[np.random.choice(len(availableIdxs), 1)[0]]
waveList[waveNo]['enemyList'][enemyIdx]['dropItemType'] = rarityBox
promisedDrops[code] = promisedDrops.get(code, 0) + 1

dt.saveJson('data/user/promisedDrops.json', promisedDrops)
Expand Down
21 changes: 13 additions & 8 deletions api/questEndpoints/send.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,16 @@ def sendArena(request,response):

numTurnsCapped = min(max(request['totalTurn'], 2), 7) # cap to 2 and 7
turnBonus = 1.0 + 0.1*(7-numTurnsCapped)
# TODO: find the other codes
opponentBonus = {'SAME': 1.0, 'HIGHER': 1.2, 'LOWER': 0.8}[userArenaBattleResult['arenaBattleOpponentType']]
consecBonus = [0,1,2,3,5,7,10][userArenaBattleResult['numberOfConsecutiveWins']]
userArenaBattle['freeRankArenaPoint'] += 10 * turnBonus * opponentBonus + consecBonus
consecBonus = [0,1,2,3,5,7,10][userArenaBattleResult['numberOfConsecutiveWins']-1]
getPoints = 10 * turnBonus * opponentBonus + consecBonus
userArenaBattle['freeRankArenaPoint'] += getPoints

userArenaBattleResult['arenaBattleStatus'] = 'WIN'
userArenaBattleResult['numberOfConsecutiveWins'] += 1
userArenaBattleResult['point'] = userArenaBattle['freeRankArenaPoint']
userArenaBattleResult['numberOfConsecutiveWins'] = userArenaBattleResult['numberOfConsecutiveWins'] % 7 + 1
userArenaBattleResult['point'] = getPoints

dt.setGameUserValue('numberOfFreeRankTotalWins', dt.getGameUserValue('numberOfFreeRankTotalWins')+1)
else:
userArenaBattleResult['arenaBattleStatus']='LOSE'
coins['quantity']+=1
Expand All @@ -49,6 +51,9 @@ def sendArena(request,response):
userArenaBattle['freeRankArenaPoint'] += 3
userArenaBattleResult['point'] = userArenaBattle['freeRankArenaPoint']

dt.setGameUserValue('freeRankArenaPoint', userArenaBattle['freeRankArenaPoint'])
gameUser = dt.setGameUserValue('numberOfFreeRankConsecutiveWins', userArenaBattleResult['numberOfConsecutiveWins'])

dt.saveJson('data/user/userArenaBattle.json', userArenaBattle)
dt.saveJson('data/user/userArenaBattleResult.json', userArenaBattleResult)

Expand All @@ -58,6 +63,7 @@ def sendArena(request,response):

resultCode="success"
response.update({
'gameUser': gameUser,
'userArenaBattle' : userArenaBattle,
'userItemList': userItemList,
'userArenaBattleResultList': [userArenaBattleResult],
Expand Down Expand Up @@ -290,11 +296,10 @@ def send():
# clear
if not cleared:
resultUserQuestBattle = storyUtil.clearBattle(battle)
storyResponse = storyUtil.progressStory(battle)
else:
resultUserQuestBattle['lastClearedAt'] = homu.nowstr()
resultUserQuestBattle['clearCount'] = resultUserQuestBattle.get('clearCount', 0) + 1
# add to stories TODO: move to only happen when first clear
storyResponse = storyUtil.progressStory(battle)
resultUserQuestBattle['clearCount'] = resultUserQuestBattle.get('clearCount', 0) + 1
# missions
battle, resultUserQuestBattle, rewardResponse = clearMissions(body, battle)

Expand Down
14 changes: 9 additions & 5 deletions api/shop.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,13 +98,14 @@ def getCC(amount):
def obtainSet(item, body, args):
for code in item['rewardCode'].split(','):
itemType = code.split('_')[0]
amount = int(code.split('_')[-1])
if itemType == 'ITEM':
args = dt.updateJson(args, getItem('_'.join(code.split('_')[1:-1]), int(code.split('_')[-1])*body['num']))
args = dt.updateJson(args, getItem('_'.join(code.split('_')[1:-1]), amount*body['num']))
elif itemType == 'RICHE':
args = dt.updateJson(args, getCC(int(code.split('_')[-1])*body['num']))
args = dt.updateJson(args, getCC(amount*body['num']))
elif itemType == 'GIFT':
args = dt.updateJson(args, getGift(int(code.split('_')[1]), int(code.split('_')[-1])*body['num']))

args = dt.updateJson(args, getGift(int(code.split('_')[1]), amount*body['num']))
def obtain(item, body, args):
if item['shopItemType'] == 'CARD':
args = dt.updateJson(args, getCard(item['card']['charaNo'], body['num']))
Expand All @@ -116,7 +117,10 @@ def obtain(item, body, args):
newGifts = getGift(int(item['gift']['rewardCode'].split('_')[1]), body['num']*int(item['rewardCode'].split('_')[-1]))
args['userGiftList'] = args.get('userGiftList', []) + newGifts['userGiftList']
elif item['shopItemType'] == 'ITEM':
newItems = getItem(item['item']['itemCode'], body['num']*int(item['rewardCode'].split('_')[-1]) if 'rewardCode' in item else 1, item['item'])
amount = 1
if 'rewardCode' in item:
amount = int(item['rewardCode'].split('_')[-1])
newItems = getItem(item['item']['itemCode'], body['num']*amount, item['item'])
args['userItemList'] = args.get('userItemList', []) + newItems['userItemList']
elif item['shopItemType'] == 'LIVE2D':
args = dt.updateJson(args, getLive2d(item['chara']['id'], item['live2d']['live2dId'], item['live2d']))
Expand Down
4 changes: 2 additions & 2 deletions api/userDeck.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ def save():
# not sure if the request ever doesn't have a deckType on the first time you edit a team
if 'deckType' in body:
deckType = body['deckType']
dt.saveJson('data/deckType.json',{'deckType': body['deckType']})
dt.saveJson('data/user/deckType.json',{'deckType': body['deckType']})
else:
deckType = dt.readJson('data/deckType.json')['deckType']
deckType = dt.readJson('data/user/deckType.json')['deckType']

userDeck = dt.getUserObject('userDeckList', deckType)
if userDeck is None:
Expand Down
6 changes: 4 additions & 2 deletions api/userPiece.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,8 @@ def setProtect(isProtected):

def setArchive(isArchive):
body = flask.request.json


resultUserPieceList = []
for pieceId in body['archiveUserPieceIdList']:
targetUserPiece = dt.getUserObject('userPieceList', pieceId)
if targetUserPiece is None:
Expand All @@ -189,10 +190,11 @@ def setArchive(isArchive):

targetUserPiece['archive'] = isArchive
dt.setUserObject('userPieceList', pieceId, targetUserPiece)
resultUserPieceList.append(targetUserPiece)

response = {
'resultCode': 'success',
'userPieceList': [targetUserPiece]
'userPieceList': resultUserPieceList
}
return flask.jsonify(response)

Expand Down
3 changes: 2 additions & 1 deletion util/storyUtil.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,14 +161,15 @@ def progressMirrors(response):
for i, arenaClass in enumerate(dt.arenaClassList[1:]):
if currPoints >= arenaClass['requiredPoint']:
arenaClassIdx = i
break
if arenaClassIdx == -1:
arenaClassIdx = len(dt.arenaClassList)-1

if dt.arenaClassList[arenaClassIdx]['arenaBattleFreeRankClass'] != response['userArenaBattle']['currentFreeRankClassType']:
response['userArenaBattle']['currentFreeRankClassType'] = dt.arenaClassList[arenaClassIdx]['arenaBattleFreeRankClass']
response['userArenaBattle']['currentFreeRankClass'] = response['userArenaBattle']['nextFreeRankClass']
if 'nextClass' in dt.arenaClassList[arenaClassIdx]:
response['userArenaBattle']['nextFreeRankClass'] = dt.arenaClassList[arenaClassIdx]
response['userArenaBattle']['nextFreeRankClass'] = dt.arenaClassList[arenaClassIdx-1]
elif 'nextFreeRankClass' in response['userArenaBattle']:
del response['userArenaBattle']['nextFreeRankClass']

Expand Down

0 comments on commit 0329b53

Please sign in to comment.