Minor change on games' files to support DLC

This commit is contained in:
Shadow15510 2022-01-26 18:45:40 +01:00
parent 495e43a590
commit 5de8f520ad
2 changed files with 119 additions and 103 deletions

View File

@ -1,5 +1,16 @@
from idk_lib import *
try:
import dlc_idk as dlc
spells = dlc.spells
spells_level = dlc.spells_level
spells_effect = dlc.spells_effect
weapons = dlc.weapons
armors = dlc.armors
except:
dlc = None
# Game
def npc(data, stat):
@ -24,6 +35,10 @@ def npc(data, stat):
h_45_npc, h_46_npc, h_47_npc, h_48_npc)
if dlc:
event = dlc.npc(data, stat)
if event: return event
return npc_core(npc_data[data[1]], data, stat)
@ -49,7 +64,10 @@ def point_of_interest(data, stat):
print(center("Island of the Dead", 21, " "))
print(center("* Kings *", 21, " "))
print("---------------------\n\nEntrez 'idk()' pour\nune nouvelle partie.")
print("---------------------")
if dlc: print(center("DLC : marchands", 21, " "))
else: print()
print("Entrez 'idk()' pour\nune nouvelle partie.")
events = {"*": npc, "?": point_of_interest}
keys = {4: display_stat, 7: spell, 8: misc_stat, 6: inventory, 9: sleep, "s": quick_save}
@ -515,13 +533,8 @@ def h_23_npc(data, stat):
54: [2, "Si j'en crois ce qui est note, cela veut dire : 'kvasir'."]
}
def h_24_npc(data, stat):
coords = data[2], data[3]
spells = ("Soin", "Flammes", "Givre", "Etincelles", "Fatigue")
levels = ("I", "II", "III", "IV", "V")
if not (480 <= stat[4] <= 1140): return [0, "Excusez-moi, nous sommes fermes."]
@ -530,7 +543,7 @@ def h_24_npc(data, stat):
if stat[9] == -1 or data[0]["main"] == stat[9]:
stat[9] = data[0]["main"]
return [0, "Quel sort souhaitez-vous oublier ?\n" + "\n".join(["{0}. {1} {2}".format(nb + 1, spells[stat[7][nb][0]], levels[stat[7][nb][1] - 1]) for nb in range(len(stat[7]))]), len(stat[7])]
return [0, "Quel sort souhaitez-vous oublier ?\n" + "\n".join(["{0}. {1} {2}".format(nb + 1, spells[stat[7][nb][0]], spells_level[stat[7][nb][1] - 1]) for nb in range(len(stat[7]))]), len(stat[7])]
else:
for i in range(1, len(stat[7]) + 1):
@ -539,37 +552,47 @@ def h_24_npc(data, stat):
stat[7].pop(i - 1)
return [-i, "Asseyez-vous, je vais vous faire oublier ce sort. [UN PUISSANT MAL DE TETE VOUS PRIT, LES MURS SEMBLERENT TANGUER TANDIS QUE VOTRE VUE DEVINT FLOUE. LE VERTIGE S'ESTOMPA PROGRESSIVEMENT.] Et voila !"]
if coords == (36, 12):
spells_sale = ((0, 2), (1, 2), (2, 4), (4, 1))
if coords == (36, 12):
if len(stat[7]) >= 3: return [0, "Je suis desole, vous ne pouvez pas apprendre plus de trois sorts."]
if stat[9] == -1 or data[0]["main"] == stat[9]:
stat[9] = data[0]["main"]
return [0, "Diomwar, pour vous servir. Quel sort voulez-vous acheter ?\n1. Soin II\n2. Flammes II\n3. Givre IV\n4. Fatigue I", 4]
spells_sale = []
formated_spells = ""
while len(spells_sale) < 3:
sp_id = randint(0, len(spells) - 1)
sp_lvl = randint(1, len(spells_level))
check = True
for sp in spells_sale:
if sp[0] == sp_id and sp[1] == sp_lvl:
check = False
break
if check:
spells_sale.append((sp_id, sp_lvl))
formated_spells += "{0}. {1} {2}\n".format(len(spells_sale), spells[sp_id], spells_level[sp_lvl - 1])
spell_choice = print_text("Diomwar, pour vous servir. Quel sort voulez-vous acheter ?\n{}".format(formated_spells), 1, 3, 0)
if not spell_choice: return [0, "Hmm ?"]
spell_sel = spells_sale[spell_choice - 1]
if stat[1] < 10 * spell_sel[1]: return [0, "Vous n'avez pas les moyens, desole."]
spell_id = -1
for sp_id in range(len(stat[7])):
sp = stat[7][sp_id]
if spell_sel[0] == sp[0]:
if spells_sel[1] <= sp[1]: return [0, "Vous connaissez deja ce sort."]
else:
spell_id = sp_id
break
if spell_id == -1:
stat[7].append(spells_sale[i])
else:
for i in range(1, 5):
if data[0]["main"] == stat[9] + i:
stat[9] = -1
if stat[1] < spells_sale[i - 1][1] * 10: return [-i, "Vous n'avez pas les moyens, desole."]
spell_id = -1
for sp_id in range(len(stat[7])):
sp = stat[7][sp_id]
if spells_sale[i - 1][0] == sp[0]:
if spells_sale[i - 1][1] <= sp[1]: return [-i, "Vous connaissez deja ce sort."]
else:
spell_id = sp_id
break
if spell_id == -1:
stat[7].append(spells_sale[i - 1])
else:
stat[7][spell_id] = spells_sale[i - 1]
return [-i, "[DIOMWAR OUVRIT UN LIVRE RELIE DE CUIR NOIR, ET TRACA DU DOIGT DES SIGNES CABALISTIQUES SUR LE SOL. LES RUNES BRILLERENT PUISSAMMENT AVANT DE S'ETEINDRE.]", 0, (1, -spells_sale[i - 1][1] * 10)]
stat[7][spell_id] = spells_sale[i]
return [0, "[DIOMWAR OUVRIT UN LIVRE RELIE DE CUIR NOIR, ET TRACA DU DOIGT DES SIGNES CABALISTIQUES SUR LE SOL. LES RUNES BRILLERENT PUISSAMMENT AVANT DE S'ETEINDRE.]", 0, (1, -10 * spells_sel[1])]
# - - - Midgard - - - #
def midgard_po(coords):
@ -620,19 +643,16 @@ def midgard_npc(data, stat):
if stat[8] % 3: return [0, "Gardim, capitaine du Mantree [IL DESIGNA UN DRAKKAR]"]
else: return [0, "Marli, assistant de feu Gardim, je peux vous renseigner ?"]
elif coords == (51, 60):
return {
"base": [0, "Hmm ?"],
0: [0, "Vous cherchez quelque chose ?\n1. Oui : Asgard.\n2. Je cherche Vanaheim.\n3. Non, tout va bien.", 3],
1: [-1, "Vous devriez essayer au nord, en passant par la foret, a l'est."],
2: [-2, "Hum, vous avez regarde du cote de la petite maison tout a l'ouest ? Un bon ami a moi, Laard est souvent a cote."],
3: [-3, "Dans ce cas... Bonne journee !"],
}
# Lithy
elif coords == (66, 56):
return {
"base": [0, "Bonjour, je suis Lithy."],
0: [0, "Vous cherchez quelque chose ?\n1. Oui : Asgard.\n2. Je cherche Vanaheim.\n3. Non, tout va bien.", 3],
1: [-1, "Vous devriez essayer au nord, en passant par la foret, a l'est."],
2: [-2, "Hum, vous avez regarde du cote de la petite maison tout a l'ouest ? Un bon ami a moi, Laard est souvent a cote."],
3: [-3, "Dans ce cas... Bonne journee !"],
27: [0, "Je suis Lithy. Les morts au combat sont repartis entre les Ases et les Vanes. Tot ou tard tu devras choisir ton camp et renier l'autre.\n1. Sur quel critere les morts sont-ils repartis ?\n2. On m'a dit que je derangeais... ?", 2],
28: [-1, "Les combattans morts lors d'attaques reviennent en general a Odin alors que ceux qui sont morts pour defendre leurs biens sont plutot l'apanage des Vanes."],
29: [0, "Votre position vous situe entre Ases et Vanes, a la veille d'une guerre comme celle-ci, les Vanes comme les Ases redoutent les informateurs caches. Vous allez devoir afficher clairement votre camp.\n1. Je suis oblige de choisir ?\n2. Comment je peux choisir ?", 2],
@ -730,6 +750,7 @@ def h_28_npc(data, stat):
57: [2, "Ah voila {} ! Skirnir vient de repartir, nous devons prendre une tour de guet de Svartalfheim. Nous passerons par Nidavellir. On se retrouve au pied de la tour.".format(stat[5])]
}
# - - - Niflheim - - - #
def niflheim_po(coords):
if coords == (88, 32): return [0, "Entoure de pierre tombales, de nombreux chemins serpentent. De lourd nuages fonces entretiennent une atmosphere pesante et une brume noiratres flotte dans l'air. Dans la penombre ambiante, une haute maison se detache, masse plus sombre encore que le reste, percee de fines fenetres et encadree de deux tours."]
@ -753,7 +774,11 @@ def niflheim_npc(data, stat):
def h_29_npc(data, stat):
coords = data[2], data[3]
spells_sale = ((0, 5), (1, 5), (2, 5), (3, 5), (4, 5))
n = len(spells)
spells_sale = [(i, len(spells_level)) for i in range(n)]
formated_spells = ""
for sp in range(n):
formated_spells += "{0}. {1} {2}\n".format(sp + 1, spells[spells_sale[sp][0]], spells_level[spells_sale[sp][1] - 1])
if not (480 <= stat[4] <= 1140): return [0, "Je suis desolee, nous sommes fermes."]
@ -762,16 +787,16 @@ def h_29_npc(data, stat):
if stat[9] == -1 or data[0]["main"] == stat[9]:
stat[9] = data[0]["main"]
return [0, "Merath, je vend les sorts les plus puissants de tout l'Yggdrasil ! Quel sort voulez-vous ?\n1. Soin V\n2. Flammes V\n3. Givre V\n4. Etincelles V\n4. Fatigue V", 4]
return [0, "Merath, je vend les sorts les plus puissants de tout l'Yggdrasil ! Quel sort voulez-vous ?\n{}".format(formated_spells), n]
else:
for i in range(1, 5):
for i in range(1, n + 1):
if data[0]["main"] == stat[9] + i:
stat[9] = -1
if stat[1] < 50: return [-i, "Vous n'avez pas les moyens, desolee."]
spell_id = -1
for sp_id, sp in range(len(stat[7])):
for sp_id in range(len(stat[7])):
sp = stat[7][sp_id]
if spells_sale[i - 1][0] == sp[0]:
if spells_sale[i - 1][1] <= sp[1]: return [-i, "Vous connaissez deja ce sort."]
@ -946,21 +971,23 @@ def h_39_npc(data, stat):
if not (480 <= stat[4] <= 1140): return [0, "La forge de Nivallir est ouverte de 8 heures a 18 heures."]
if coords == (9, 2):
if stat[3][0]: return [0, "Vous avez deja une arme. Allez voir mon confrere si vous voulez la vendre et revenez me voir."]
elif stat[9] == -1 or data[0]["main"] == stat[9]:
stat[9] = data[0]["main"]
return [0, "Bienvenue a la forge de Nidavellir ! Vous desirez une piece particulière ?\n1. Un marteau [-20 PO]\n2. Une masse [-30 PO]\n3. Un fleau [-40 PO]\n4. Une hache [-50 PO]", 4]
weapons_sale = []
formated_wpn = ""
while len(weapons_sale) < 4:
wpn = randint(1, len(weapons) - 1)
if not wpn in weapons_sale:
weapons_sale.append(wpn)
formated_wpn += "{0}. {1} [-{2} PO]\n".format(len(weapons_sale), weapons[wpn], 10 * wpn)
else:
weapons = ("UN MARTEAU", "UNE MASSE", "UN FLEAU", "UNE HACHE")
for i in range(1, 5):
if data[0]["main"] == stat[9] + i:
stat[9] = -1
if stat[1] < (i+1) * 10: return [-i, "Vous n'avez pas assez."]
stat[3][0] = i + 1
return [-i, "Tres bon choix ! [LE NAIN DECROCHA {} DU RATELIER ET VOUS TENDIT L'ARME.]".format(weapons[i - 1]), 0, (1, -(i+1) * 10)]
wpn_choice = print_text("Bienvenue a la forge de Nidavellir ! Vous desirez une piece particulière ?\n{}".format(formated_wpn), 1, 4, 0)
if not wpn_choice: return [0, "Hmm ?"]
wpn = weapons_sale[wpn_choice - 1]
if stat[1] < 10 * wpn: return [0, "Vous n'avez pas assez."]
stat[3][0] = wpn
return [0, "Tres bon choix ! [LE NAIN DECROCHA L'ARME DU RATELIER ET VOUS LA TENDIT.]", 0, (1, -10 * wpn)]
if coords == (9, 4):
if stat[3][0] == 0: return [0, "Vous n'avez pas d'arme a me vendre. Allez voir mon collegue pour en acheter une."]
@ -990,7 +1017,7 @@ def h_41_npc(data, stat):
# - - - Muspellheim - - - #
def muspellheim_po(coords):
if coords == (66, 8): return [0, "La mer s'etendait, calme. Bosquets et maisons peuplaient la cote, dont plusieurs petite tentes."]
if coords == (66, 8): return [0, "La mer s'etendait, calme. Bosquets et maisons peuplaient la cote. Quelques petites tentes pointues ponctuaient le tout, bravant la brise marine par une fine enveloppe de cuir tanne."]
elif coords == (64, 97): return [0, "La cloture de la propriete etait ouvragee, le manoir aussi. Constitue d'un corps de ferme rehabilite et entoure de deux tours decoratives, l'ensemble conservait un air propre et entretenu. Le jardin taille en temoigne."]

View File

@ -32,6 +32,12 @@ maps = (
h_42, h_43, h_44,
h_45, h_46, h_47, h_48)
spells = ("Soin", "Flammes", "Givre", "Etincelles", "Fatigue")
spells_level = ("I", "II", "III", "IV", "V")
spells_effect = ((0, 1, True), (4, -1, False), (4, -1, False), (4, -1, False), (0, -1, False)) # (capacity, factor, True on player; False on opponent)
weapons = ("<aucune>", "Dague", "Marteau", "Masse", "Fleau", "Hache", "Epee", "Espadon", "Hache double")
armors = ("<aucune>", "Rondache", "Pavois", "Cote de maille", "Broigne", "Harnois")
# Asci functions
def npc_core(event_fn, data, stat):
event = event_fn(data, stat)
@ -68,7 +74,7 @@ def npc_core(event_fn, data, stat):
def launch_fight(data, stat, event, quest="main"):
issue = fight(stat, event[0], event[1])
issue, stat[0] = fight(stat, event[0], event[1])
if issue == 0:
stat[1] += event[2]
@ -128,46 +134,32 @@ def fight(stat, opponent_stat, opponent_name):
if len(stat[7]) == 0:
msg += "\nVous ne connaissez pas de sort."
else:
spell_data = ("Soin", "Flammes", "Givre", "Etincelles", "Fatigue")
spell_level = ("I", "II", "III", "IV", "V")
spell_choice = 0
while not spell_choice:
print("\n" * 6 + "Sort(s) connu(s) :")
count = 0
for spell_id, level in stat[7]:
print("{0}. {1} {2}".format(count + 1, spell_data[spell_id], spell_level[level - 1]))
print("{0}. {1} {2}".format(count + 1, spells[spell_id], spells_level[level - 1]))
count += 1
spell_choice = get_input()
if spell_choice < 0 or spell_choice > 3: spell_choice = 0
spell_choice -= 1
name, level = spell_data[stat[7][spell_choice][0]], stat[7][spell_choice][1]
spell_id, level = stat[7][spell_choice][0], stat[7][spell_choice][1]
if stat[2][4] >= level * 10:
msg += "\nVous lancez {0} de niveau {1} [-{2} PM].".format(name, spell_level[level - 1], level * 10)
msg += "\nVous lancez {0} de niveau {1} [-{2} PM].".format(spells[spell_id], spells_level[level - 1], level * 10)
stat[2][4] -= level * 10
pts = 12 * level + randint(-5, 5)
if stat[7][spell_choice][0] == 0:
stat[0] += pts
msg += "\nVous gagnez {} PV".format(pts)
elif stat[7][spell_choice][0] == 1:
opponent_stat[4] -= pts
msg += "\n{0} perd {1} PV".format(opponent_name, pts)
elif stat[7][spell_choice][0] == 2:
opponent_stat[4] -= pts
msg += "\n{0} perd {1} PV".format(opponent_name, pts)
elif stat[7][spell_choice][0] == 3:
opponent_stat[4] -= pts
msg += "\n{0} perd {1} PV".format(opponent_name, pts)
elif stat[7][spell_choice][0] == 4:
opponent_stat[0] -= pts
msg += "\n{0} perd {1} points de vitesse".format(opponent_name, 12 * level)
capacity, factor, apply_on_player = spells_effect[spell_id]
if apply_on_player:
player_stat[capacity] += factor * pts
msg += "\nVous {0} {1} points de {2}".format(("perdez", "gagnez")[factor > 0], pts, ("vitesse", "agilité", "attaque", "défense", "vie")[capacity])
else:
opponent_stat[capacity] += factor * pts
msg += "\n{0} {1} {2} points de {3}".format(opponent_name, ("perd", "gagne")[factor > 0], pts, ("vitesse", "agilité", "attaque", "défense", "vie")[capacity])
else:
msg += "\nVous ne parvenez pas a lancer le sort."
@ -191,14 +183,14 @@ def fight(stat, opponent_stat, opponent_name):
elif stat_test(player_stat, 1)[0]:
msg += "\n{} esquive le coup.".format(stat[5])
else:
stat[0] -= damage
player_stat[4] -= damage
msg += "\n{0} perd {1} PV.".format(stat[5], damage)
print_text(msg)
# opponent_stat = [vitesse, agilité, attaque, défense, vie]
# player_stat = [vitesse, agilité, attaque, défense]
player_stat = [stat[2][0], stat[2][1], stat[2][2] + stat[3][0] * 5, stat[2][3] + stat[3][1] * 5]
# player_stat = [vitesse, agilité, attaque, défense, vie]
player_stat = [stat[2][0], stat[2][1], stat[2][2] + stat[3][0] * 5, stat[2][3] + stat[3][1] * 5, stat[0]]
end = False
while not end:
@ -217,7 +209,7 @@ def fight(stat, opponent_stat, opponent_name):
p_capacities = ["{} ".format(i) if i < 10 else str(i) for i in player_stat]
o_capacities = ["{} ".format(i) if i < 10 else str(i) for i in opponent_stat[:-1]]
p_health = str(stat[0]) + " " * (3 - len(str(stat[0])))
p_health = str(player_stat[4]) + " " * (3 - len(str(player_stat[4])))
o_health = str(opponent_stat[4]) + " " * (3 - len(str(opponent_stat[4])))
print(" Joueur | Ennemi")
@ -243,18 +235,18 @@ def fight(stat, opponent_stat, opponent_name):
if player > opponent:
end = player_turn()
if end: return 2
if opponent_stat[4] <= 0: return 0
if opponent_stat[4] <= 0: return 0, player_stat[4]
opponent_turn()
else:
opponent_turn()
if stat[0] <= 0: return 1
if player_stat[4] <= 0: return 1, player_stat[4]
end = player_turn()
if opponent_stat[4] <= 0: return 0
if stat[0] <= 0: return 1
if opponent_stat[4] <= 0: return 0, player_stat[4]
if player_stat[4] <= 0: return 1, player_stat[4]
return 2
return 2, player_stat[4]
def misc_stat(data, stat):
@ -306,8 +298,8 @@ def display_stat(data, stat):
def inventory(data, stat):
weapon = ("<aucune>", "Dague", "Marteau", "Masse", "Fleau", "Hache", "Epee", "Espadon", "Hache double")[stat[3][0]]
shield = ("<aucune>", "Rondache", "Pavois", "Cote de maille", "Broigne", "Harnois")[stat[3][1]]
weapon = weapons[stat[3][0]]
shield = armors[stat[3][1]]
weapon = " |" + weapon + " " * (17 - len(weapon)) + "|"
shield = " |" + shield + " " * (17 - len(shield)) + "|"
@ -327,22 +319,19 @@ def sleep(data, stat):
if sleep_hours < 0: sleep_hours = 0
stat[4] += sleep_hours * 60
if stat[0] < 100: stat[0] += sleep_hours
if stat[2][4] < 50: stat[2][4] += sleep_hours // 2
if stat[0] < 100: stat[0] += sleep_hours // 2
if stat[2][4] < 50: stat[2][4] += sleep_hours // 4
# If the player is at home
if data[1] == 27:
if stat[0] < 100: stat[0] += 5 * sleep_hours
if stat[0] < 100: stat[0] += 2 * sleep_hours
if stat[2][4] < 50: stat[2][4] += sleep_hours // 2
print_text("Vous vous reposez {0} heure{1}.".format(sleep_hours, ("", "s")[sleep_hours > 1]))
def spell(data, stat):
spell_data = ("Soin", "Flammes", "Givre", "Etincelles", "Fatigue")
spell_level = ("I", "II", "III", "IV", "V")
to_disp = "Magie : {} PM".format(stat[2][4])
print("<o> Sorts <o>")
print(" |" + to_disp + " " * (16 - len(to_disp)) + "|")
@ -351,7 +340,7 @@ def spell(data, stat):
if i < len(stat[7]):
spell_id, level = stat[7][i]
if spell_id >= 0:
to_disp = "{0} {1}".format(spell_data[spell_id], spell_level[level - 1])
to_disp = "{0} {1}".format(spells[spell_id], spells_level[level - 1])
print(" |" + to_disp + " " * (16 - len(to_disp)) + "|")
else:
print(" |<aucun> |")