Skip to content

Commit

Permalink
Merge pull request #33 from GalvinGao/master
Browse files Browse the repository at this point in the history
  • Loading branch information
GalvinGao authored May 5, 2022
2 parents f3916d2 + 7b169bd commit fb8e226
Show file tree
Hide file tree
Showing 58 changed files with 255 additions and 167 deletions.
32 changes: 32 additions & 0 deletions .github/workflows/build-image.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Build Docker Image

on:
push:
# trigger on any tag push
tags:
- "**"
concurrency:
group: ${{ github.ref }}
cancel-in-progress: true

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2

- name: Get Tag Version
id: get_version
run: |
export TRUNCATED_GITHUB_SHA=$(echo ${{ github.sha }} | cut -c1-7);
echo "VERSION=${GITHUB_REF/refs\/tags\//}+${TRUNCATED_GITHUB_SHA}" >> $GITHUB_ENV
echo "GIT_TAG=${GITHUB_REF/refs\/tags\//}" >> $GITHUB_ENV
- name: Build and Publish to Registry
uses: elgohr/[email protected]
with:
name: penguin-statistics/planner-backend
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
registry: ghcr.io
tags: "latest,${{ env.GIT_TAG }}"
Binary file removed ArkPlannerWeb/.DS_Store
Binary file not shown.
1 change: 0 additions & 1 deletion ArkPlannerWeb/css/app.de424562.css

This file was deleted.

1 change: 0 additions & 1 deletion ArkPlannerWeb/css/chunk-vendors.723a90c8.css

This file was deleted.

Binary file removed ArkPlannerWeb/fonts/element-icons.535877f5.woff
Binary file not shown.
Binary file removed ArkPlannerWeb/fonts/element-icons.732389de.ttf
Binary file not shown.
Binary file removed ArkPlannerWeb/img/30011_icon.c00897ee.png
Binary file not shown.
Binary file removed ArkPlannerWeb/img/30012_icon.c30a1101.png
Binary file not shown.
Binary file removed ArkPlannerWeb/img/30013_icon.b220a6ed.png
Binary file not shown.
Binary file removed ArkPlannerWeb/img/30014_icon.fa3b13cd.png
Binary file not shown.
Binary file removed ArkPlannerWeb/img/30021_icon.7efa3d78.png
Binary file not shown.
Binary file removed ArkPlannerWeb/img/30022_icon.50fffa0d.png
Binary file not shown.
Binary file removed ArkPlannerWeb/img/30023_icon.b2d7a7d3.png
Binary file not shown.
Binary file removed ArkPlannerWeb/img/30024_icon.39697e6f.png
Binary file not shown.
Binary file removed ArkPlannerWeb/img/30031_icon.de03560a.png
Binary file not shown.
Binary file removed ArkPlannerWeb/img/30032_icon.014870c4.png
Binary file not shown.
Binary file removed ArkPlannerWeb/img/30033_icon.d1ec4620.png
Binary file not shown.
Binary file removed ArkPlannerWeb/img/30034_icon.e074f91e.png
Binary file not shown.
Binary file removed ArkPlannerWeb/img/30041_icon.25e8a60e.png
Binary file not shown.
Binary file removed ArkPlannerWeb/img/30042_icon.30c63c87.png
Binary file not shown.
Binary file removed ArkPlannerWeb/img/30043_icon.353c5786.png
Binary file not shown.
Binary file removed ArkPlannerWeb/img/30044_icon.667e42d6.png
Binary file not shown.
Binary file removed ArkPlannerWeb/img/30051_icon.ea6de092.png
Binary file not shown.
Binary file removed ArkPlannerWeb/img/30052_icon.67fb4afd.png
Binary file not shown.
Binary file removed ArkPlannerWeb/img/30053_icon.684af6a0.png
Binary file not shown.
Binary file removed ArkPlannerWeb/img/30054_icon.df31b4e0.png
Binary file not shown.
Binary file removed ArkPlannerWeb/img/30061_icon.6de269c4.png
Binary file not shown.
Binary file removed ArkPlannerWeb/img/30062_icon.fd26231f.png
Binary file not shown.
Binary file removed ArkPlannerWeb/img/30063_icon.015ea05d.png
Binary file not shown.
Binary file removed ArkPlannerWeb/img/30064_icon.f1ffd506.png
Binary file not shown.
Binary file removed ArkPlannerWeb/img/30073_icon.ac0159a1.png
Binary file not shown.
Binary file removed ArkPlannerWeb/img/30074_icon.a6fb6ff1.png
Diff not rendered.
Binary file removed ArkPlannerWeb/img/30083_icon.6fe39f46.png
Diff not rendered.
Binary file removed ArkPlannerWeb/img/30084_icon.55048777.png
Diff not rendered.
Binary file removed ArkPlannerWeb/img/30093_icon.b8825244.png
Diff not rendered.
Binary file removed ArkPlannerWeb/img/30094_icon.0c494831.png
Diff not rendered.
Binary file removed ArkPlannerWeb/img/30103_icon.d6c778db.png
Diff not rendered.
Binary file removed ArkPlannerWeb/img/30104_icon.9fbc224b.png
Diff not rendered.
Binary file removed ArkPlannerWeb/img/30115_icon.56e7eb15.png
Diff not rendered.
Binary file removed ArkPlannerWeb/img/30125_icon.872e77fc.png
Diff not rendered.
Binary file removed ArkPlannerWeb/img/30135_icon.8ff1c85b.png
Diff not rendered.
Binary file removed ArkPlannerWeb/img/31013_icon.64364374.png
Diff not rendered.
Binary file removed ArkPlannerWeb/img/31014_icon.cf1b2c75.png
Diff not rendered.
Binary file removed ArkPlannerWeb/img/31023_icon.09368c26.png
Diff not rendered.
Binary file removed ArkPlannerWeb/img/31024_icon.d155ca46.png
Diff not rendered.
1 change: 0 additions & 1 deletion ArkPlannerWeb/index.html

This file was deleted.

2 changes: 0 additions & 2 deletions ArkPlannerWeb/js/app.acc74794.js

This file was deleted.

1 change: 0 additions & 1 deletion ArkPlannerWeb/js/app.acc74794.js.map

This file was deleted.

28 changes: 0 additions & 28 deletions ArkPlannerWeb/js/chunk-vendors.94c00031.js

This file was deleted.

1 change: 0 additions & 1 deletion ArkPlannerWeb/js/chunk-vendors.94c00031.js.map

This file was deleted.

14 changes: 14 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
FROM python:3.10.2-slim-bullseye

COPY . .

RUN apt-get update && apt-get install -y \
tini
# Tini is now available at /usr/bin/tini

RUN pip install --no-cache-dir -r requirements.txt

EXPOSE 8020

ENTRYPOINT ["/usr/bin/tini", "--"]
CMD [ "python", "-m", "sanic", "server.app", "--host=0.0.0.0", "--port=8020", "--workers=2" ]
139 changes: 99 additions & 40 deletions MaterialPlanning.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def __init__(self,
update=False,
banned_stages={},
# expValue=30,
ConvertionDR=0.18,
# ConvertionDR=0.18,
display_main_only=True):
"""
Object initialization.
Expand All @@ -39,9 +39,15 @@ def __init__(self,
"""
self.banned_stages = banned_stages # for debugging
self.display_main_only = display_main_only
self.ConvertionDR = ConvertionDR
self.ConvertionDR = 0.18 # send actual convertion_dr in get_plan

self.update(force=update)
self.update(force=update,
filter_freq=filter_freq,
filter_stages=filter_stages,
url_stats=url_stats,
url_rules=url_rules,
path_stats=path_stats,
path_rules=path_rules)

def get_item_id(self):
items = get_json('items')
Expand Down Expand Up @@ -93,35 +99,48 @@ def _pre_processing(self, material_probs):
stage_array.append(drop['stageId'])
stage_dct_rv = {v: k for k, v in enumerate(stage_array)}
servers = ['CN', 'US', 'JP', 'KR']
# CN have to be the first one, which contain all possible stages
languages = ['zh', 'en', 'ja', 'ko']

valid_stages = {server: [False]*len(stage_array) for server in servers}
stage_code = {server: ['' for _ in stage_array] for server in servers}
complete_stage_list = {server: [] for server in servers}
stage_update_list = {server: [] for server in servers}
stages = {}
stage_name_rv = {lang: {} for lang in languages}
stage_id_to_name = {}
for server in servers:
try:
stages[server] = get_json(f'stages?server={server}')
stages[server] = [stage for stage in stages[server] if stage['existence'][server]['exist']]
except Exception as e:
print(f'Failed to load server {server}, Error: {e}')
return -1
for stage in stages[server]:
if stage['code'] not in complete_stage_list[server]:
complete_stage_list[server].append(stage['code'])
if stage['stageId'] not in stage_dct_rv or 'dropInfos' not in stage:
if stage['code'][:2] in ['SK', 'AP', 'CE', 'LS', 'PR']:
stage_update_list[server].append(stage)
continue
valid_stages[server][stage_dct_rv[stage['stageId']]] = True
stage_code[server][stage_dct_rv[stage['stageId']]] = stage['code_i18n'][LanguageMap[server]]
for lang in languages: stage_name_rv[lang][stage['code_i18n'][lang]] = stage_dct_rv[stage['stageId']]
stage_code[server][stage_dct_rv[stage['stageId']]] = stage['code_i18n'][LanguageMap[server]]
for lang in languages:
stagecode = stage['code_i18n'][lang]
if stagecode not in stage_name_rv[lang]:
stage_name_rv[lang][stagecode] = []
stage_name_rv[lang][stagecode].append(stage_dct_rv[stage['stageId']])
stage_id_to_name[stage['stageId']] = {lang: stage['code_i18n'][lang] for lang in languages}
# Fix KeyError('id')
stage_id_to_name[stage['stageId']]["id"] = stage['stageId']

try:
self.get_item_id()
except Exception as e:
print(f'Failed to load item list, Error: {e}')
return -1

self.complete_stage_list = complete_stage_list
self.stage_array = stage_array
self.stage_dct_rv = stage_dct_rv
self.stage_code = stage_code
Expand All @@ -136,8 +155,27 @@ def _pre_processing(self, material_probs):
for stage in stages[server]:
if stage['stageId'] in self.stage_dct_rv:
self.cost_lst[self.stage_dct_rv[stage['stageId']]] = stage['apCost']

self.update_stage()

for server in servers:
#print([stage['code'] for stage in stage_update_list[server]])
for stage in stage_update_list[server]:
if stage['stageId'] not in self.stage_array:
self.stage_array.append(stage['stageId'])
self.stage_dct_rv.update({stage['stageId']: len(self.stage_array)-1})
for a_server in servers:
self.valid_stages[a_server].append(False)
self.stage_code[a_server].append('')
self.cost_lst = np.append(self.cost_lst, stage['apCost'])
self.valid_stages[server][stage_dct_rv[stage['stageId']]] = True
self.stage_code[server][stage_dct_rv[stage['stageId']]] = stage['code_i18n'][LanguageMap[server]]
for lang in languages:
stagecode = stage['code_i18n'][lang]
if stagecode not in stage_name_rv[lang]:
self.stage_name_rv[lang][stagecode] = []
self.stage_name_rv[lang][stagecode].append(stage_dct_rv[stage['stageId']])
self.stage_id_to_name[stage['stageId']] = {lang: stage['code_i18n'][lang] for lang in languages}
self.stage_id_to_name[stage['stageId']]["id"] = stage['stageId']

self.stage_array = np.array(self.stage_array)
self.probs_matrix = np.zeros([len(self.stage_array), len(self.item_array)])

Expand All @@ -147,13 +185,12 @@ def _pre_processing(self, material_probs):
except:
print(f'Failed to parse {drop}. (出现此条请带报错信息联系根派)')

# 添加LS, CE, S4-6, S5-2等的掉落 及 默认龙门币掉落
# 添加所有关卡的龙门币掉落
for k, stage in enumerate(self.stage_array):
self.probs_matrix[k, self.item_name_rv['龙门币']] = self.cost_lst[k]*12
self.update_droprate()


# To build equavalence relationship from convert_rule_dct.
# To build equivalence relationship from convert_rule_dct.
self.update_convertion()
self.convertions_dct = {}
convertion_matrix = []
Expand All @@ -176,7 +213,8 @@ def _pre_processing(self, material_probs):
for iname in outc_dct:
convertion[self.item_name_rv[iname]] += outc_dct[iname]*self.ConvertionDR*outc_wgh[iname]/weight_sum
convertion_outc_matrix.append(convertion)
convertion_cost_lst.append(0)
convertion_cost_lst.append(1e-8 * rule['goldCost'])
# a small factor, since here we do not know whether we demand gold or not

self.convertion_matrix = np.array(convertion_matrix)
self.convertion_outc_matrix = np.array(convertion_outc_matrix)
Expand Down Expand Up @@ -403,6 +441,7 @@ def alive(stage):
items = {self.item_id_to_name[self.item_array[idx]][output_lang]: float2str(probs_matrix[i, idx]*t)
for idx in target_items if len(self.item_array[idx])==5 and self.item_array[idx] != 'furni'}
stage = {
"stageId": stage_array[i],
"stage": self.stage_id_to_name[stage_array[i]][output_lang],
"count": float2str(t),
"items": items
Expand Down Expand Up @@ -448,7 +487,7 @@ def alive(stage):
print('Loot at following stages:')
for stage in stages:
display_lst = [k + '(%s) '%stage['items'][k] for k in stage['items']]
print('Stage ' + self.stage_code[server][self.stage_name_rv[output_lang][stage['stage']]]
print('Stage ' + self.stage_code[server][self.stage_dct_rv[stage['stageId']]]
+ '(%s times) ===> '%stage['count'] + ', '.join(display_lst))

print('\nSynthesize following items:')
Expand All @@ -468,19 +507,43 @@ def is_gold_or_exp(self, stage_name):
return self.stage_code['CN'][self.stage_dct_rv[stage_name]][:2] in ['LS', 'CE']

def update_droprate(self):
self.update_droprate_processing('S4-6', '龙门币', 3228)
self.update_droprate_processing('S5-2', '龙门币', 2484)
self.update_droprate_processing('1-1', '龙门币', 660, 'update')
self.update_droprate_processing('2-7', '龙门币', 1500, 'update')
self.update_droprate_processing('3-6', '龙门币', 2040, 'update')
self.update_droprate_processing('4-1', '龙门币', 2700, 'update')
self.update_droprate_processing('6-1', '龙门币', 1216, 'update')
self.update_droprate_processing('7-3', '龙门币', 1216, 'update')
self.update_droprate_processing('R8-1', '龙门币', 2700, 'update')
self.update_droprate_processing('R8-4', '龙门币', 1216, 'update')
self.update_droprate_processing('9-2', '龙门币', 2700, 'update')
self.update_droprate_processing('9-3', '龙门币', 1216, 'update')
self.update_droprate_processing('10-8', '龙门币', 3480, 'update')

self.update_droprate_processing('S2-2', '龙门币', 1020, 'update')
self.update_droprate_processing('S4-6', '龙门币', 3480, 'update')
self.update_droprate_processing('S5-2', '龙门币', 2700, 'update')
self.update_droprate_processing('S5-3', '龙门币', 1216, 'update')
self.update_droprate_processing('S5-5', '龙门币', 1216, 'update')
self.update_droprate_processing('S6-2', '龙门币', 1216, 'update')
self.update_droprate_processing('S6-4', '龙门币', 2700, 'update')
self.update_droprate_processing('S7-1', '龙门币', 2700, 'update')
self.update_droprate_processing('S7-2', '龙门币', 1216, 'update')

self.update_droprate_processing('CE-1', '龙门币', 1700, 'update')
self.update_droprate_processing('CE-2', '龙门币', 2800, 'update')
self.update_droprate_processing('CE-3', '龙门币', 4100, 'update')
self.update_droprate_processing('CE-4', '龙门币', 5700, 'update')
self.update_droprate_processing('CE-5', '龙门币', 7500, 'update')
self.update_droprate_processing('LS-1', '作战记录', 1600, 'update')
self.update_droprate_processing('LS-2', '作战记录', 2800, 'update')
self.update_droprate_processing('LS-3', '作战记录', 3900, 'update')
self.update_droprate_processing('LS-4', '作战记录', 5900, 'update')
self.update_droprate_processing('LS-5', '作战记录', 7400, 'update')
self.update_droprate_processing('CE-6', '龙门币', 10000, 'update')

self.update_droprate_processing('LS-6', '高级作战记录', 4, 'update')
self.update_droprate_processing('LS-6', '中级作战记录', 2, 'update')

#self.update_droprate_processing('LS-1', '作战记录', 1600, 'update')
#self.update_droprate_processing('LS-2', '作战记录', 2800, 'update')
#self.update_droprate_processing('LS-3', '作战记录', 3900, 'update')
#self.update_droprate_processing('LS-4', '作战记录', 5900, 'update')
#self.update_droprate_processing('LS-5', '作战记录', 7400, 'update')

def update_convertion_processing(self, target_item: tuple, cost: int, source_item: dict, extraOutcome: dict):
'''
Expand All @@ -504,45 +567,41 @@ def update_convertion(self):
self.update_convertion_processing(('作战记录', 200), 0, {'基础作战记录': 1}, ({}, 0, 1))
self.update_convertion_processing(('作战记录', 400), 0, {'初级作战记录': 1}, ({}, 0, 1))
self.update_convertion_processing(('作战记录', 1000), 0, {'中级作战记录': 1}, ({}, 0, 1))
self.update_convertion_processing(('作战记录', 1000), 0, {'高级作战记录': 1}, ({}, 0, 1))
self.update_convertion_processing(('作战记录', 2000), 0, {'高级作战记录': 1}, ({}, 0, 1))
# 这里一定保证这一条在最后!
# ENSURE THIS LINE IS THE LAST LINE!
self.update_convertion_processing(('作战记录', 400), 0, {'赤金': 1}, ({}, 0, 1))

def update_stage(self):
self.update_stage_processing('LS-1', 10, 'wk_kc_1')
self.update_stage_processing('LS-2', 15, 'wk_kc_2')
self.update_stage_processing('LS-3', 20, 'wk_kc_3')
self.update_stage_processing('LS-4', 25, 'wk_kc_4')
self.update_stage_processing('LS-5', 30, 'wk_kc_5')
self.update_stage_processing('CE-1', 10, 'wk_melee_1')
self.update_stage_processing('CE-2', 15, 'wk_melee_2')
self.update_stage_processing('CE-3', 20, 'wk_melee_3')
self.update_stage_processing('CE-4', 25, 'wk_melee_4')
self.update_stage_processing('CE-5', 30, 'wk_melee_5')

def update_stage_processing(self, stage_name: str, cost: int, code: str) -> None:
if code in self.stage_array:
print(f'stage {stage_name} already included')
self.stage_array.append(code)
self.stage_dct_rv.update({code: len(self.stage_array)-1})
if stage_name not in self.stage_name_rv['zh']:
self.stage_name_rv['zh'][stage_name] = []
self.stage_name_rv['zh'][stage_name].append(len(self.stage_array)-1)

self.cost_lst = np.append(self.cost_lst, cost)
servers = ['CN', 'US', 'JP', 'KR']
for server in servers:
self.stage_code[server].append(stage_name)
self.valid_stages[server].append(True)

def update_droprate_processing(self, stage, item, droprate, mode='add'):
# update droprate for all stages that has code $stage
if stage not in self.stage_name_rv['zh']:
print(f'stage {stage} not found')
if stage not in self.complete_stage_list['CN']:
print(f'stage {stage} not found')
return
if item not in self.item_name_rv:
print(f'item {item} not found')
return
stageid = self.stage_name_rv['zh'][stage]
itemid = self.item_name_rv[item]
if mode == 'add':
self.probs_matrix[stageid][itemid] += droprate
elif mode == 'update':
self.probs_matrix[stageid][itemid] = droprate
for stageid in self.stage_name_rv['zh'][stage]:
itemid = self.item_name_rv[item]
if mode == 'add':
self.probs_matrix[stageid][itemid] += droprate
elif mode == 'update':
self.probs_matrix[stageid][itemid] = droprate


def get_json(s):
Expand Down
Loading

0 comments on commit fb8e226

Please sign in to comment.