Change mecanics and begin quests

This commit is contained in:
Shadow15510 2021-11-14 18:22:03 +01:00
parent d9136ef635
commit d0cb6e2519
5 changed files with 142 additions and 83 deletions

View File

@ -137,7 +137,6 @@ class Asci:
# Get the event
event = self._game_events_mapping[cell_content](data_copy, self.stat)
event = read_event(self.data[0], event)
# data modification
self.data[0] = data_copy[0]
@ -145,6 +144,9 @@ class Asci:
if data_copy[2] != x: self.data[2] = data_copy[2]
if data_copy[3] != y: self.data[3] = data_copy[3]
if not event: return
event = read_event(self.data[0], event)
# XP and stat modification
self.data[0] += event.xp_earned
for index, value in event.stat:

View File

@ -42,8 +42,8 @@ asgard = (r"""
##### |o|o|o|o|o|o| ### | | ~~~~~~~~~~~~~ ~~~~~~ /-\ |_| ##### ~~~~ /\ /
##### /_____________\ ##### ### ### ~~~~~~~~~~~~ ~~~~~~~~ |^| _ ~~~~~ / \ /\
#### |_/ \_/ \_| ### ##### ##### ### ~~~~~~~~~~~~~~~~ ~~~~~~~~~ /o\ ~~~~ / \ / \
|| |_| |^| |_| /-\ ### ### ### ##### ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |_| ~~~~ / \ / \
## * /-\ /-\ ##### ### ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~ / /
|| |_| |^| |_| /-\ ### ### ### ##### ~~~~~~~~~~~~~~| |~~~~~~~~~~~~~~~ |_| ~~~~ / \ / \
## * /-\ /-\ ##### ### ~~~~~~~| |~~~~~~~~~~~~~~~~~~ ~~~~ / /
#### ### ### /-\ ~~~~~~~~~~~~~ ~~~~~ /\ /
###### ##### ### ### ### /-\ ### ___________ ~~~~~~~~~~ ~~~~~~ / \ /
###### ### ##### ##### ##### ~~~ ##### /Thrymrheimr\ ~~~~~~~~~~~~~~~~~~ /\ / \ /
@ -150,7 +150,12 @@ h_9 = (r"""
(15, 13, 0, 30, 11)) # * : (19, 4)
def h_9_npc(data, stat):
pass
coords = data[2], data[3]
xp = data[0]
if coords == (19, 4): return {
"base": [0, "Forseti, fils de Baldr et Nanna, dieu de la Justice. Tu as besoin de moi ?"]
}
@ -192,13 +197,13 @@ def h_10_npc(data, stat):
print(coords)
if coords == (25, 11):
if xp == 0:
stat[3][0] = 5
return [1, "Je suis Odin, Roi des Ases. Commencons par une premiere quete simple. Nous, les Ases, avons quelques differents avec les Vanes. Vous irez donc porter cette hache a Freyja. Elle comprendra. [ODIN VOUS DONNE UNE HACHE]"]
stat[3][0] = 1
return [1, "Je suis Odin, Roi des Ases. Actuellement nous avons quelques differents avec les Vanes. Vous irez donc porter cette dague a Freyja, a Vanaheim. Elle comprendra. [ODIN VOUS DONNE UNE DAGUE]"]
else: return {
"base": [0, "Je suis Odin, Roi des Ases, dieux de la Guerre."],
1: [0, "Deja revenu !?"],
2: [0, "C'est une declaration de guerre ! [ODIN SE LEVA, FURIEUX]"],
3: [1, "Bien. Tu peux garder la dague, une guerre se prepare, ce serait bete de mourrir deux fois quand meme ? [UN SOURIRE PASSA SUR LES LEVRES D'ODIN] Jadis Freyja m'enseigna la magie et l'astrologie. [ODIN SE FIT PENSIF]. Je te ferais savoir mes instructions en temps voulu. Je crois qu'il te reste quelques mondes a decouvrir."]
}

View File

@ -63,9 +63,30 @@ def npc(data, stat):
elif type(event) == tuple:
issue = fight(stat, event[0], event[1])
if issue == 0:
stat[1] += event[2]
return [1, "Vous avez gagne le combat. [+{}PO]".format(event[2])]
if sum(stat[2][:-1]) >= 200: return [1, "Vous avez gagne le combat. [+{}PO]".format(event[2])]
print_text("Vous avez gagne le combat. [+{}PO]".format(event[2]))
data[0] += 1
choice = 0
while not choice:
print("<o> Amelioration <o>")
print(" |1. Vitesse |")
print(" |2. Agilite |")
print(" |3. Attaque |")
print(" |4. Defense |")
print("<o> ============= <o>")
choice = get_input()
if (choice < 0 or choice > 4) and stat[2][choice - 1] >= 50: choice = 0
print_text("Vous gagnez 2 points {}".format(("de vitesse", "d'agilite", "d'attaque", "de defense")[choice - 1]))
stat[2][choice - 1] += 2
if stat[2][choice -1] > 50: stat[2][choice - 1] = 50
return None
elif issue == 1: return [0, "Vous etes mort."]
elif issue == 2: return [0, "Vous avez fuit."]
@ -111,76 +132,91 @@ def fight(stat, opponent_stat, opponent_name):
def player_turn():
end = False
print_text("Tour de {}".format(stat[5]))
msg = "Tour de {}".format(stat[5])
if choice == 1:
damage = 2 * stat_test(player_stat, 2)[2] - opponent_stat[3]
damage = stat_test(player_stat, 2)[1] - opponent_stat[3]
if damage < 0: damage = 0
if damage == 0:
print_text("{} bloque l'attaque.".format(opponent_name))
msg += "\n{} bloque l'attaque.".format(opponent_name)
elif stat_test(opponent_stat[:-1], 1)[0]:
print_text("{} esquive le coup.".format(opponent_name))
msg += "\n{} esquive le coup.".format(opponent_name)
else:
opponent_stat[4] -= damage
print_text("{0} perd {1} PV.".format(opponent_name, damage))
msg += "\n{0} perd {1} PV.".format(opponent_name, damage)
elif choice == 2:
if len(stat[8]) == 0:
print_text("Vous ne connaissez pas de sort.")
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[8]:
print("{0}. {1} {2}".format(count + 1, spell_data[spell_id], spell_level[level]))
print("{0}. {1} {2}".format(count + 1, spell_data[spell_id], spell_level[level - 1]))
count += 1
spell_choice = get_input()
if spell_choice < 0 or spell_choice > 3: spell_choice = 0
spell_choice -= 1
spell_name, level = spell_data[stat[8][spell_choice][0]], stat[8][spell_choice][1] + 1
name, level = spell_data[stat[8][spell_choice][0]], stat[8][spell_choice][1]
if stat[2][4] >= level * 10:
print_text("Vous lancez {0} de niveau {1} [-{2} PM].".format(name, spell_level[level - 1]))
msg += "\nVous lancez {0} de niveau {1} [-{2} PM].".format(name, spell_level[level - 1], level * 10)
stat[2][4] -= level * 10
pts = 12 * level + randint(-5, 5)
if stat[8][spell_choice][0] == 0:
stat[0] += 12 * level
stat[0] += pts
msg += "\nVous gagnez {} PV".format(pts)
elif stat[8][spell_choice][0] == 1:
opponent_stat[4] -= 12 * level
opponent_stat[4] -= pts
msg += "\n{0} perd {1} PV".format(opponent_name, pts)
elif stat[8][spell_choice][0] == 2:
opponent_stat[4] -= 12 * level
opponent_stat[4] -= pts
msg += "\n{0} perd {1} PV".format(opponent_name, pts)
elif stat[8][spell_choice][0] == 3:
opponent_stat[4] -= 12 * level
opponent_stat[4] -= pts
msg += "\n{0} perd {1} PV".format(opponent_name, pts)
elif stat[8][spell_choice][0] == 4:
opponent_stat[0] -= 12 * level
opponent_stat[0] -= pts
msg += "\n{0} perd {1} points de vitesse".format(opponent_name, 12 * level)
else:
print_text("Vous ne parvenez pas a lancer le sort.")
msg += "\nVous ne parvenez pas a lancer le sort."
elif choice == 3:
if stat_test(player_stat, 1)[0]:
end = True
else:
print_text("Votre tentative de fuite echoue.")
msg += "\nVotre tentative de fuite echoue."
print_text(msg)
return end
def opponent_turn():
print_text("Tour de {}".format(opponent_name))
damage = 2 * stat_test(opponent_stat, 2)[2] - player_stat[3]
msg = "Tour de {}".format(opponent_name)
damage = stat_test(opponent_stat, 2)[1] - player_stat[3]
if damage < 0: damage = 0
if damage == 0:
print_text("{} bloque l'attaque.".format(stat[5]))
msg += "\n{} bloque l'attaque.".format(stat[5])
elif stat_test(player_stat, 1)[0]:
print_text("{} esquive le coup.".format(stat[5]))
msg += "\n{} esquive le coup.".format(stat[5])
else:
stat[0] -= damage
print_text("{0} perd {1} PV.".format(stat[5], 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]
@ -226,19 +262,21 @@ def fight(stat, opponent_stat, opponent_name):
if player > opponent:
end = player_turn()
if end: return 2
if opponent_stat[4] > 0: opponent_turn()
else: return 0
if opponent_stat[4] <= 0: return 0
opponent_turn()
else:
opponent_turn()
if stat[0] > 0: end = player_turn()
else: return 1
if stat[0] <= 0: return 1
end = player_turn()
if opponent_stat[4] <= 0: return 0
if stat[0] <= 0: return 1
return 2
def misc_stat(data, stat):
# stat = [0 - PV, 1 - pièces d'or, 2 - [vitesse, agilité, attaque, defense, magie], 3 - [arme, armure], 4 - ticks, 5 - nom, 6 - (temps, xp), 7 - classe, 8 - sorts connus : (id, level)]
if data[1] < 9: place = ("Asgard", "Vanaheim", "Alfheim", "Midgard", "Niflheim", "Jotunheim", "Nidavellir", "Muspellheim", "Helheim")[data[1]]
else: place = "interieur"
money, ticks, player_class = stat[1], stat[4], stat[7]
@ -300,7 +338,6 @@ def inventory(data, stat):
def sleep(data, stat):
if 360 < stat[4] < 1140:
print_text("Vous ne pouvez pas dormir de jour.")
return
@ -341,6 +378,7 @@ keys = {4: display_stat, 7: spell, 8:misc_stat, 6: inventory, 9: sleep}
# Main function
def idk(stat=None, data=None):
# stat = [0 - PV, 1 - pièces d'or, 2 - [vitesse, agilité, attaque, defense, magie], 3 - [arme, armure], 4 - ticks, 5 - nom, 6 - (temps, xp), 7 - classe, 8 - sorts connus : (id, level), 9 - sous-quête en cours]
if not stat:
name = ""
while len(name) == 0 or len(name) > 13:
@ -359,11 +397,13 @@ def idk(stat=None, data=None):
elif player_class == 3:
stat = [5, 5, 5, 10, 5]
elif player_class == 4:
stat = [5, 5, 5, 5, 10]
stat = [5, 5, 5, 5, 20]
elif player_class == 5:
stat = [10, 5, 5, 5, 5]
stat = [100, 10, stat, [0, 0], 360, name, (-1, -1), player_class - 1, []]
stat = [100, 10, stat, [0, 0], 360, name, (-1, -1), player_class - 1, [], 0]
if player_class == 4:
stat[8].append((1, 1))
data = [0, 3, 44, 66]
print_text("Au alentour du Ve siecle, quelque part en Scandinavie. La bataille prenait place dans un champ saccage, et la nuit etait tombe depuis quelques heures lorsque l'assaut debuta.")
@ -394,9 +434,6 @@ def center(string, total_length, symbol):
def stat_test(stat, test_id):
avg = sum(stat) / len(stat)
score = stat[test_id] + randint(0, ceil(avg / 2))
return score >= avg, score / avg, score
score = (80 + randint(-20, 20)) * stat[test_id] / 50
return randint(1, 100) <= score, floor(score)

View File

@ -84,7 +84,7 @@ midgard = (r"""
~~~~~~~~~ ### ### /|\ ##### /|\ ~~~~~~~~~~
~~~~~~~~ /|\ ##### ### ### ### ### ~~~~~~~~~
~~~~~~~~ ##### ### /|\ ##### ##### ##### ### |--|--|--|~~~~
~~~~~~~~~ ### ### ##### ##### ### ### ##### |~~~~
~~~~~~~~~ ### ### ##### ##### ### ### ##### *|~~~~
~~~~~~~~~~ ##### /|\ ##### ### ### /|\ /|\ ### |~~~~
~~~~~~~~~~~ ##### ### ##### /|\ /|\ |--|--|--|~~~~
~~~~~~~~~~~~~ ### _ /|\ ##### ### ### ~~~~~~~~~~~
@ -120,35 +120,37 @@ def midgard_po(coords):
elif coords == (52, 79): return [0, "Tournant le dos a l'epais mur qui delimite la propriete, vous observez le manoir. Le corps du batiment etait clairement une ancienne ferme a laquelle deux tours on ete rajoute a posteriori. L'ensemble garde un aspect massif et froid. Neanmoins, le reste de la propriete a fait l'objet d'un certain soin, en particulier le jardin en 4 parties dans lequel un vieux jardinier s'affaire."]
def midgard_npc(data, stat):
# (67, 46)
# (39, 49)
# (66, 56)
# (51, 60)
# (68, 71)
coords = data[2], data[3]
xp = data[0]
if coords == (67, 46): return {
"base": [0, "Oui ?..."]
}
elif coords == (39, 49): return {
"base": [0, "Vous cherchez quelqu'un ?"]
}
elif coords == (66, 56):
return [0, "Hein ?"]
elif coords == (8, 59): return {
"base": [0, "Regardez la mer. Et si vous voyez un bateau, prevenez moi !"]
}
elif coords == (51, 60): return {
"base": [0, "Besoin de quelque chose ?"]
}
elif coords == (68, 71):
if xp == 0:
return [5, 5, 10, 5, 20], "Frinir", 0
if coords == (8, 59):
if stat[9] == 1: return {
7: [0, "En clair, j'aimerais que tu elimines Gardim. La paye sera bonne."],
8: [1, "C'est un grand service que tu m'a rendu l'ami, je ne l'oublierai pas ! [+10PO]", 0, (1, 10), (9, -1)]
}
else: return {
"base": [0, "Frinir, jardinier de Madame."]
}
"base": [0, "Laard, je suis marin de mon etat."],
4: [0, "Laard, marin. Vous cherchez un engagement ?\n1. Hmm ? Proposez toujours ?\n2. Désolé, j'ai d'autres affaires a regler.", 2],
5: [2, "Voila, il y a quelques temps j'ai embarque dans un navire. Malheureusement, Njord ne nous a pas ete favorable : la tempete nous a surpris. La situation a bord est devenue tendue, nous nous sommes mutines. En represailles, Gardim, le capitaine, a fait passer quelques matelots par dessus bord. J'ai jure de les venger, mais je ne connais rien aux armes. Tu peux t'en charger pour moi ?", 0, (9, 1)],
6: [-2, "Je comprends."],
}
elif coords == (94, 85):
if stat[9] == 1:
if xp < 7:
return [0, "Gardim, capitaine du Mantree [IL DESIGNA UN DRAKKAR]"]
elif xp == 7:
return [5, 2, 7, 7, 30], "Gardim", 3
else: return {
"base": [0, "[A VOS PIEDS S'ETEND LE CORPS FROID DE GARDIM.]"]
}
@ -207,7 +209,7 @@ def h_26_npc(data, stat):
# Rosahil Green
if coords == (27, 6):
if stat[4] >= 1320 and stat[4] <= 340: return [0, "Je suis desolee, nous sommes fermes. Revenez plus tard !"]
if stat[4] >= 1320 or stat[4] <= 340: return [0, "Je suis desolee, nous sommes fermes. Revenez plus tard !"]
if stat[6][1] == -1:
stat[6] = stat[4], data[0]
@ -216,7 +218,7 @@ def h_26_npc(data, stat):
elif data[0] == stat[6][1] + 1:
stat[6] = (-1, -1)
if stat[1] < 5: return [-1, "Reviens quand tu auras assez de pieces d'or."]
return [-1, "Et voila pour vous !", 0, (0, 5), (1, -5)]
return [-1, "Et voila pour vous ! [ROSAHIL POSA UNE ASSIETTE DE RAGOUT CHAUD DEVANT VOUS.]", 0, (0, 5), (1, -5)]
elif data[0] == stat[6][1] + 2:
stat[6] = (-1, -1)
@ -226,7 +228,7 @@ def h_26_npc(data, stat):
stat[4] = 360
return [-2, "Suivez-moi, je vais vous montrer votre chambre. [VOUS SUIVEZ ROSAHIL DANS L'AUBERGE, LA NUIT PASSA.]", 0, (0, 10), (1, -10)]
return [0, "Ui hips ?"]
else: return [0, "Ui hips ?"]

View File

@ -27,7 +27,7 @@ vanaheim = (r"""
\ / \ /\ / ### / \ ' /<>\ ` /|\ / \ /
\ / \ /|\ |_| . |__| .' / \ /\ /
\ /\ / \ ` ``' ### , _ / \ / \
/ \ / \ /\ _ ##### ', /-\ / \
/ \ / \ /\ _ ##### ', /o\ / \
/ \ / \ . / \ ### , |_| /\ \ /
/ \ /\ / \ |_| /|\ , * ` / \ /
/ \ / \ ,. _ ',` '' / \ /\
@ -65,7 +65,12 @@ vanaheim = (r"""
# * : (45; 39)
def vanaheim_npc(data, stat):
pass
coords = data[2], data[3]
xp = data[0]
if coords == (31, 12): return {
"base": [0, "Riethas, simple paysan. Que Nerthus vous garde !"],
}
def vanaheim_po(coords):
if coords == (42, 20): return [0, "Vous vous trouvez sur le bord d'une large place verdoyante et bien entretenue. Entoure de montagnes, Vanaheim semble hors d'atteinte du temps. Quelques maisons et arbres completent le decor."]
@ -111,7 +116,7 @@ def h_21_npc(data, stat):
stat[4] = 360
return [-3, "Votre chambre est a l'etage.\n[LA NUIT PASSE]", 0, (0, 10), (1, -10)]
return [0, "Je grois qu'j'ais trop buurrps."]
return [0, "Ch'rois hips qu'j'ais hips trop buu'hips."]
@ -144,23 +149,31 @@ def h_22_npc(data, stat):
xp = data[0]
# Freyja
if coords == (36, 3):
if coords == (2, 8):
if not (360 <= stat[4] <= 1200):
return [0, "Revenez plus tard s'il vous plait."]
if xp == 1:
stat[8].append((0, 1))
return [1, "Hum. [FREYJA REGARDE LA HACHE] Odin me propose la paix... Mais ca ne se passera pas comme ca. [ELLE VOUS REND LA HACHE]. Allez voir Odin, et rendez-lui sa hache. En remerciement de vos services, je vous apprend le sort de Soin. [FREYJA DESSINA DU DOIGT DES RUNES VIOLETTE DANS L'AIR. LES LETTRES LUMINEUSES BRILLERENT UN INSTANT AVANT DE S'ESTOMPER PROGRESSIVEMENT.]"]
return [0, "Revenez plus tard s'il vous plait : il fait nuit."]
else: return {
"base": [0, "Bonjour, je suis Freyja, deesse de la beaute et de l'erotisme."]
"base": [0, "Bonjour, je suis Freyja, deesse de la beaute et de l'erotisme."],
1: [1, "Hum. [FREYJA REGARDE LA DAGUE] Odin me propose la paix... Mais cela ne se passera pas comme ca. [ELLE VOUS REND LA DAGUE]. Rendez sa dague a Odin. Avant que vous ne partiez pour Asgard, allez voir Freyr, il est dans la piece adjacente."],
}
# Freyr
elif coords == (2, 8):
elif coords == (36, 3):
if (not 360 <= stat[4] <= 1200):
return [0, "Hein ? Quoi ? Ca va pas non ? Qu'est-ce qu'il vous a pris de me reveiller comme ca ?"]
if xp == 2:
check = True
for spell_id, spell_level in stat[8]:
if spell_id == 0: check = False
if check:
stat[8].append((0, 1))
return [1, "Chez les Vanes, nous rendons hommage aux messagers, en guise de remerciement, je vais vous apprendre le sort de Soin [FREYR DESSINA DANS L'AIR DES RUNES VIOLETTE QUI TOURNOYERENT UN INSTANT AVANT DE S'ESTOMPER PEU A PEU.]"]
else:
return [1, "Chez les Vanes, nous rendons hommage aux messagers, voici quelques pieces d'or, faites en bon usage !", 0, (1, 5)]
else: return {
"base": [0, "Freyr, dieu de la vie. Bienvenue a Vanaheim"]
}