こんばんわ~ ٩( ‘ω’ )و
ちょっと作業に待ち時間ができたので、ザッと作ってみました ٩( ´ᆺ`)۶
import random
#プレイヤーステータス
p_hp = 100 #現在HP(体力)
p_mhp = 100 #最大HP
p_mp = 100 #現在MP(魔力)
p_mmp = 100 #最大MP
p_str = 100 #攻撃力
p_vit = 100 #防御力
p_int = 100 #知力
p_dex = 100 #器用さ
p_agi = 100 #素早さ
p_luk = 100 #運
#プレイヤー武器ステータス
p_watk = 100 #物理攻撃力
p_wmatk = 100 #魔法攻撃力
p_wei = 100 #重量クラス(重(120以上)、普(重と軽の間)、軽(80以下))
p_wskl = 100 #熟練度
#プレイヤー防具ステータス
p_adef = 100 #物理防御力
p_amdef = 100 #魔法防御力
#プレイヤースキルのステータス
p_skl = 100 #スキル値(通常攻撃時は100、スキル使用時は100以上)
#エネミーステータス
e_hp = 100 #現在HP(体力)
e_mhp = 100 #最大HP
e_mp = 100 #現在MP(魔力)
e_mmp = 100 #最大MP
e_str = 100 #攻撃力
e_vit = 100 #防御力
e_int = 100 #知力
e_dex = 100 #器用さ
e_agi = 100 #素早さ
e_luk = 100 #運
#エネミー武器ステータス
e_watk = 100 #物理攻撃力
e_wmatk = 100 #魔法攻撃力
e_wei = 100 #重量クラス(重(120以上)、普(重と軽の間)、軽(80以下))
e_wskl = 100 #熟練度
#エネミー防具ステータス
e_adef = 100 #物理防御力
e_amdef = 100 #魔法防御力
#エネミースキルのステータス
e_skl = 100 #スキル値(通常攻撃時は100、スキル使用時は100以上)
#プレイヤー戦闘時計算値
p_atk = (p_str + p_watk * p_wskl / 100) * p_wei / 100 * p_skl / 100 #物理攻撃値
p_matk = (p_int + p_wmatk * p_wskl / 100) * p_skl / 100 #魔法攻撃値
p_def = p_vit + p_adef #物理防御値
p_mdef = (p_vit + p_int) / 2 + p_amdef #魔法防御値
p_avos = p_agi - (e_agi + e_dex / 2) #回避値(素早さ)
p_avol = p_luk - e_luk #回避値(運)
p_avof = False #回避フラグ
p_crif = False #クリティカルフラグ
p_atkf = False #攻撃実行フラグ
p_spd = 0.0 #ターンスピード
#エネミー戦闘時計算値
e_atk = (e_str + e_watk * e_wskl / 100) * e_wei / 100 * e_skl / 100 #物理攻撃値
e_matk = (e_int + e_wmatk * e_wskl / 100) * e_skl / 100 #魔法攻撃値
e_def = e_vit + e_adef #物理防御値
e_mdef = (e_vit + e_int) / 2 + e_amdef #魔法防御値
e_avos = e_agi - (p_agi + p_dex / 2) #回避値(素早さ)
e_avol = e_luk - p_luk #回避値(運)
e_avof = False #回避フラグ
e_crif = False #クリティカルフラグ
e_atkf = False #攻撃実行フラグ
e_spd = 0.0 #ターンスピード
p_dam = p_atk - e_def * 0.8 #プレイヤー⇒エネミー 物理ダメージ
p_mdam = p_matk - e_mdef * 0.8 #プレイヤー⇒エネミー 魔法ダメージ
e_dam = e_atk - p_def * 0.8 #エネミー⇒プレイヤー 物理ダメージ
e_mdam = e_matk - p_mdef * 0.8 #エネミー⇒プレイヤー 魔法ダメージ
self.bIsRunning = True
try:
while(True):
#ターン計算
p_spd = p_spd + p_agi / (p_wei / 10)
if(p_spd > 100.0):
p_atkf = True
p_spd = p_spd - 100.0
e_spd = e_spd + e_agi / (e_wei / 10)
if(e_spd > 100.0):
e_atkf = True
e_spd = e_spd - 100.0
#プレイヤー行動
if(p_atkf):
sentence = "プレイヤーの攻撃"
id = self.tts.post.say(str(sentence))
self.ids.append(id)
self.tts.wait(id, 0)
p_atkf = False
#エネミー回避判定(素早さ)
if(e_avos >= 100):
if(random.randint(0,1) == 1):
e_avof = True
elif(e_avos >= 90):
if(random.randint(1,20) >= 12):
e_avof = True
elif(e_avos >= 80):
if(random.randint(1,5) >= 4):
e_avof = True
elif(e_avos >= 70):
if(random.randint(1,20) >= 14):
e_avof = True
elif(e_avos >= 60):
if(random.randint(1,5) >= 3):
e_avof = True
elif(e_avos >= 50):
if(random.randint(1,4) == 4):
e_avof = True
elif(e_avos >= 40):
if(random.randint(1,5) >= 5):
e_avof = True
elif(e_avos >= 30):
if(random.randint(1,20) >= 18):
e_avof = True
elif(e_avos >= 20):
if(random.randint(1,5) >= 5):
e_avof = True
elif(e_avos >= 10):
if(random.randint(1,20) >= 20):
e_avof = True
#エネミー回避判定(運)
if(not(e_avof)):
if(e_avol >= 100):
if(random.randint(1,5) >= 2):
e_avof = True
elif(e_avol >= 90):
if(random.randint(1,25) >= 8):
e_avof = True
elif(e_avol >= 80):
if(random.randint(1,25) >= 10):
e_avof = True
elif(e_avol >= 70):
if(random.randint(1,25) >= 12):
e_avof = True
elif(e_avol >= 60):
if(random.randint(1,25) >= 14):
e_avof = True
elif(e_avol >= 50):
if(random.randint(1,5) >= 4):
e_avof = True
elif(e_avol >= 40):
if(random.randint(1,25) >= 18):
e_avof = True
elif(e_avol >= 30):
if(random.randint(1,25) >= 20):
e_avof = True
elif(e_avol >= 20):
if(random.randint(1,25) >= 22):
e_avof = True
elif(e_avol >= 10):
if(random.randint(1,25) >= 24):
e_avof = True
#プレイヤークリティカル判定
if(p_avol >= 100):
if(random.randint(1,20) == 20):
p_crif = True
elif(p_avol >= 80):
if(random.randint(1,25) == 25):
p_crif = True
elif(p_avol >= 60):
if(random.randint(1,100) >= 98):
p_crif = True
elif(p_avol >= 40):
if(random.randint(1,50) == 50):
p_crif = True
elif(p_avol >= 20):
if(random.randint(1,100) == 100):
p_crif = True
#戦闘計算
if(not(e_avof)):
if(p_dam > 0):
if(random.randint(0,1) == 0):
if(p_crif):
sentence = "クリティカル!!"
id = self.tts.post.say(str(sentence))
self.ids.append(id)
self.tts.wait(id, 0)
p_dam = (p_dam - random.randint(0,10)) * 2
else:
p_dam = p_dam - random.randint(0,10)
else:
if(p_crif):
sentence = "クリティカル!!"
id = self.tts.post.say(str(sentence))
self.ids.append(id)
self.tts.wait(id, 0)
p_dam = (p_dam + random.randint(0,10)) * 2
else:
p_dam = p_dam + random.randint(0,10)
e_hp = e_hp - p_dam
else:
sentence = "攻撃は避けられた!!"
id = self.tts.post.say(str(sentence))
self.ids.append(id)
self.tts.wait(id, 0)
if(e_hp <= 0):
sentence = "敵を倒した!! 経験値:0 (ぇ"
id = self.tts.post.say(str(sentence))
self.ids.append(id)
self.tts.wait(id, 0)
break
e_avof = False
p_crif = False
#エネミー行動
if(e_atkf):
sentence = "敵の攻撃"
id = self.tts.post.say(str(sentence))
self.ids.append(id)
self.tts.wait(id, 0)
e_atkf = False
#プレイヤー回避判定(素早さ)
if(p_avos >= 100):
if(random.randint(0,1) == 1):
p_avof = True
elif(p_avos >= 90):
if(random.randint(1,20) >= 12):
p_avof = True
elif(p_avos >= 80):
if(random.randint(1,5) >= 4):
p_avof = True
elif(p_avos >= 70):
if(random.randint(1,20) >= 14):
p_avof = True
elif(p_avos >= 60):
if(random.randint(1,5) >= 3):
p_avof = True
elif(p_avos >= 50):
if(random.randint(1,4) == 4):
p_avof = True
elif(p_avos >= 40):
if(random.randint(1,5) >= 5):
p_avof = True
elif(p_avos >= 30):
if(random.randint(1,20) >= 18):
p_avof = True
elif(p_avos >= 20):
if(random.randint(1,5) >= 5):
p_avof = True
elif(p_avos >= 10):
if(random.randint(1,20) >= 20):
p_avof = True
#プレイヤー回避判定(運)
if(not(p_avof)):
if(p_avol >= 100):
if(random.randint(1,5) >= 2):
p_avof = True
elif(p_avol >= 90):
if(random.randint(1,25) >= 8):
p_avof = True
elif(p_avol >= 80):
if(random.randint(1,25) >= 10):
p_avof = True
elif(p_avol >= 70):
if(random.randint(1,25) >= 12):
p_avof = True
elif(p_avol >= 60):
if(random.randint(1,25) >= 14):
p_avof = True
elif(p_avol >= 50):
if(random.randint(1,5) >= 4):
p_avof = True
elif(p_avol >= 40):
if(random.randint(1,25) >= 18):
p_avof = True
elif(p_avol >= 30):
if(random.randint(1,25) >= 20):
p_avof = True
elif(p_avol >= 20):
if(random.randint(1,25) >= 22):
p_avof = True
elif(p_avol >= 10):
if(random.randint(1,25) >= 24):
p_avof = True
#エネミークリティカル判定
if(e_avol >= 100):
if(random.randint(1,20) == 20):
e_crif = True
elif(e_avol >= 80):
if(random.randint(1,25) == 25):
e_crif = True
elif(e_avol >= 60):
if(random.randint(1,100) >= 98):
e_crif = True
elif(e_avol >= 40):
if(random.randint(1,50) == 50):
e_crif = True
elif(e_avol >= 20):
if(random.randint(1,100) == 100):
e_crif = True
#戦闘計算
if(not(p_avof)):
if(e_dam > 0):
if(random.randint(0,1) == 0):
if(e_crif):
sentence = "クリティカル!!"
id = self.tts.post.say(str(sentence))
self.ids.append(id)
self.tts.wait(id, 0)
e_dam = (e_dam - random.randint(0,10)) * 2
else:
e_dam = e_dam - random.randint(0,10)
else:
if(e_crif):
sentence = "クリティカル!!"
id = self.tts.post.say(str(sentence))
self.ids.append(id)
self.tts.wait(id, 0)
e_dam = (e_dam + random.randint(0,10)) * 2
else:
e_dam = e_dam + random.randint(0,10)
p_hp = p_hp - e_dam
else:
sentence = "敵の攻撃を避けた!!"
id = self.tts.post.say(str(sentence))
self.ids.append(id)
self.tts.wait(id, 0)
if(p_hp <= 0):
sentence = "プレイヤーは息絶えた … ただの屍のようだ …"
id = self.tts.post.say(str(sentence))
self.ids.append(id)
self.tts.wait(id, 0)
break
p_avof = False
e_crif = False
とりあえず動くって感じで、ステータスもガチなので、もう少し調整したものを今週末に上げれたらいいなぁという感じです (/ω\)
福岡でロボット開発といえば、株式会社システムトランジスタ
(通称シストラ)ロボティクス部マキマキのカキコミでした~ _φ(・ω・ )