Skip to content

Commit

Permalink
版本推进至3.3.21,提供支持牌堆市场的相关接口
Browse files Browse the repository at this point in the history
  • Loading branch information
lunzhiPenxil committed Oct 23, 2023
1 parent e5a7857 commit a974d9b
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 5 deletions.
4 changes: 2 additions & 2 deletions OlivaDiceCore/app.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
"namespace" : "OlivaDiceCore",
"message_mode" : "old_string",
"info" : "本模块为OlivaDice的核心模块,提供了所有必须的骰子功能以及基础的管理支持,几乎所有的其它模块都依赖这个模块。",
"version" : "3.3.20",
"svn" : 1070,
"version" : "3.3.21",
"svn" : 1071,
"compatible_svn" : 101,
"priority" : 20000,
"support" : [
Expand Down
4 changes: 2 additions & 2 deletions OlivaDiceCore/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@
import OlivOS

OlivaDiceCore_name = 'OlivaDice核心模块'
OlivaDiceCore_ver = '3.3.20'
OlivaDiceCore_svn = 1070
OlivaDiceCore_ver = '3.3.21'
OlivaDiceCore_svn = 1071
OlivaDiceCore_ver_short = '%s(%s)' % (str(OlivaDiceCore_ver), str(OlivaDiceCore_svn))

exce_path = os.getcwd()
Expand Down
38 changes: 38 additions & 0 deletions OlivaDiceCore/drawCard.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import traceback
import random
import codecs
import traceback

# 兼容OlivOS 0.10.2及以下版本
try:
Expand Down Expand Up @@ -158,6 +159,40 @@ def setDeckIndex(bot_hash:str, deck_name:str, deck_data:dict):
]
OlivaDiceCore.drawCardData.dictDeckIndex[bot_hash][deck_name] = deck_data_list

# 清空牌堆数据
def cleanDeck():
for botInfo in OlivaDiceCore.drawCardData.dictDeck:
OlivaDiceCore.drawCardData.dictDeck[botInfo] = {}
for botInfo in OlivaDiceCore.drawCardData.dictDeckIndex:
OlivaDiceCore.drawCardData.dictDeckIndex[botInfo] = {}

# 重载牌堆数据
# 目前不会清理牌堆帮助文档数据,所以如果发生牌堆减量将会导致牌堆帮助文档数据残留
# 但是我认为这个问题不明显,用户应该不在意 By lunzhiPenxil
def reloadDeck():
if OlivaDiceCore.data.global_Proc != None \
and 'bot_info_dict' in OlivaDiceCore.data.global_Proc.Proc_data:
bot_info_dict = OlivaDiceCore.data.global_Proc.Proc_data['bot_info_dict']
cleanDeck()
initDeck(bot_info_dict = bot_info_dict)

# 根除指定牌堆
def removeDeck(deckName:str, botHash:str):
checkDict = {
'deckclassic': ['json', 'json5'],
'deckyaml': ['yaml'],
'deckexcel': ['xlsx', 'xls']
}
for deck_type in ['deckclassic', 'deckyaml', 'deckexcel']:
for dfix in checkDict.get(deck_type, []):
deck_path = os.path.join('plugin', 'data', 'OlivaDice', botHash, 'extend', deck_type, deckName + '.' + dfix)
if os.path.exists(deck_path):
try:
os.remove(deck_path)
except Exception as e:
traceback.print_exc()

# 初始化牌堆数据
def initDeck(bot_info_dict):
dictTValue = OlivaDiceCore.msgCustom.dictTValue.copy()
dictStrConst = OlivaDiceCore.msgCustom.dictStrConst
Expand Down Expand Up @@ -209,6 +244,7 @@ def initDeck(bot_info_dict):
elif customDeckFile.endswith('.json'):
customDeckFile = customDeckFile.rstrip('.json')
setDeckIndex(botHash, customDeckFile, obj_Deck_this)
setDeckIndex('unity', customDeckFile, obj_Deck_this)
# 全局 yaml 牌堆
obj_Deck_this = None
releaseDir(OlivaDiceCore.data.dataDirRoot + '/unity/extend/deckyaml')
Expand Down Expand Up @@ -244,6 +280,7 @@ def initDeck(bot_info_dict):
botHash = bot_info_dict_this
OlivaDiceCore.drawCardData.dictDeck[botHash].update(obj_Deck_this_new)
setDeckIndex(botHash, customDeckFile_deckName, obj_Deck_this_new)
setDeckIndex('unity', customDeckFile_deckName, obj_Deck_this_new)
# 全局 excel 牌堆
releaseDir(OlivaDiceCore.data.dataDirRoot + '/unity/extend/deckexcel')
customDeckDir = OlivaDiceCore.data.dataDirRoot + '/unity/extend/deckexcel'
Expand Down Expand Up @@ -294,6 +331,7 @@ def initDeck(bot_info_dict):
botHash = bot_info_dict_this
OlivaDiceCore.drawCardData.dictDeck[botHash].update(obj_Deck_this_new)
setDeckIndex(botHash, customDeckFile_new, obj_Deck_this_new)
setDeckIndex('unity', customDeckFile_new, obj_Deck_this_new)
# 全局 牌堆 日志
if botHash != None:
obj_Deck_this_count_total = len(OlivaDiceCore.drawCardData.dictDeck[botHash])
Expand Down
6 changes: 5 additions & 1 deletion OlivaDiceCore/msgReply.py
Original file line number Diff line number Diff line change
Expand Up @@ -3309,7 +3309,6 @@ def unity_reply(plugin_event, Proc):
tmp_res_list_this.append('%2d' % rd_this.resInt)
tmp_sum += rd_this.resInt
tmp_res_list.append([tmp_res_list_this, '%3d' % tmp_sum])
print(tmp_res_list)
dictTValue['tPcTempName'] = tmp_pcCardTemplateName
dictTValue['tPcInitResult'] = '\n' + '\n'.join([
'[%s] : %s' % (', '.join(tmp_res_list_this[0]), tmp_res_list_this[1])
Expand Down Expand Up @@ -5371,3 +5370,8 @@ def getMatchWordStartRight(data, key, ignoreCase = True):
if tmp_data[:len(tmp_key)] == tmp_key:
tmp_output_str = data[len(key):]
return tmp_output_str

def isdigitSafe(data):
if data in '0123456789':
return True
return False

0 comments on commit a974d9b

Please sign in to comment.