diff --git a/ideas.txt b/ideas.txt index c09f0a8..9de7235 100644 --- a/ideas.txt +++ b/ideas.txt @@ -1,11 +1,64 @@ features : make different areas for start -merchant -make flee chance dependent on mob with a parameter -make quests +random merchants +make flee chance dependent on mob with a parameter (eg : speed or agility) + stamina left +make quests procedurally generated +make floors for the dungeon with floor bosses +make semi random champions and elites spawns +make around village exploration richer, find items, encounter merchants, being ambushed +make choices done by key presses instead of typing a enter each time +randomize some properties like power or health points +make undead monsters have a living state instead of a specific species => abiity for damage types to be efficient against undead + original species +find a way to use ranks but differenciate numeral ranks from letter ranks +make a random name (composed of syllabs) engine for village names +make defined major NPC in a list but make random npc register by characters so it randomizes for every player +add a tag system to make specific damage easier : dictionary of tags inside the dictionary of each template and definition +maybe : include exchange between characters if possible + +save feature : +save the boolean for creation and feeding of databases => python file or external file ? +save characters by player and one folder containing all the save file for each player + +exploration feature : +integration wanted : exploration => combat OR merchant OR find item OR find place OR find tumb with epitaphs or items... make a small random to have events playing in the dungeon such as find an item, see a monster and decide to attack or not, find a chest, a hidden way, or a trap +make a counter in case randomness chooses too many times in a row the same monster (store monster name, increment counter, if counter > x then choose another monster) +OR implement dictionaries to have monster frequencies +OR keep the list and make a dictionary with a zip against a list of frequencies +make environment types have a certain difficulty factor : for monsters that appear and climatic events like sandstorms or snow storms, floods... for random funny events +hardcoded dungeons are handplaced into the world, but procedurally generated ones can appear virtually anywhere -debug : +combat feature : +make combat decisions based on character class +make subfunctions for combat turns so I can decide for initiative from the player or from the monster +make another function for choosen combat when the exploration function gives the monster itself, which will call subfunctions +make an arena system with opponent lists (raised monsters, human classes) with another combat function called arena +make a combat loop or partial loop for the arena to be able to alter coins and XP gains +humans have a specific arena characteristic for coins because there will be clandestine arena battles in the wild + +death handling feature : +if resurrection function called, it will handle XP and coin losses and resurrect player at 50% life +if not called, ironman mode is activated, and that character is deleted from memory + +npc feature : +random npc : names, surnames, nicknames, origin (country, continent, city), specialization (job, class), personalities +make dictionaries for each characteristic -find why the global variable doesn't work for the save of player's data when going out an in the dungeon \ No newline at end of file +statistics feature : +add stats to character templates and definitions +differenciate main and secondary stats +derived stats formulas => + +classes feature : +make classes real dictionnaries to choose from +each class will call it's own definition and template upon choice + +transform : +dungeon function to have choice which then leads to other functions +exploration function to be different depending on environment around villages + +final before continuing dev : +=> separate functions into files : done for database ! + +debug : diff --git a/precisions.txt b/precisions.txt new file mode 100644 index 0000000..8d0f832 --- /dev/null +++ b/precisions.txt @@ -0,0 +1,92 @@ +LISTS : + +human list : + +humanoid list : +corrupted humans => will have some human origins and different levels and ranks +corrupted elves => dark, high, wood, blood (unique to corrupted ones), crystal (crystal elves are elves imprisoned in stone by an ancient curse, end game enemy) +corrupted dwarves => deep, high, forest, blood (same as elves counterpart), crystal (same) +beastmen => centaur, lizardman, wolfman, foxman, tigerman, lionman, dogman, catman, goatman, cowman +homonculii => homonculus, + +pseudohumanoid list : +goblinoids => goblin, hobgoblin, goblin warrior, goblin lieutenant, goblin chief, goblin priest, goblin general, goblin king, goblin emperor +orcoids => orc, high orc, orc warrior, orc priest, orc chief, orc general, orc king +ogres => ogre, red ogre, green ogre, blue ogre, black ogre, white ogre, mutant ogre, demonic ogre, kijin = divine ogre + +undead list : +vampire list => +zombie list => zombie, ghoul, plant zombie (corpse invaded by plants), zombie beast, lich, archlich, dracolich +skeleton list => skeleton, skeleton warrior, skeleton mage, skeleton knight, skeleton general, skeletal beast, skeletal demon, skeletal dragon +ghost list => dead spirit, ghost, fallen spirit, corrupted spirit +specter list => specter, wraith, fantom, poltergheist, animal specter, divine specter + +demon list : +demonic beast => demonic animal (choose species), +lesser demon => imp, great imp, +medium demon => +greater demon => +high demon => +lords => +archdemon => + +spirit list : +elemental => nymph, djinn, +magic => djinn, +divine => djinn (named), Sylphide (wind), Callypso (water), Ifrit (fire), + +slimy list : +slime => slime (base), glutton slime, plant slime, carrion slime, poison slime, rocky slime, metal slime, crytal slime (base slime but can harden to protect itself), +mana slime (mana fluid charged base slime) +mud => animated mud, muddy corpse (undead too) +gel => + +beast list : +animal => +deformed animal => +animal spirit => + +insectoid list : +flying => +creeping => +digging => + +vegetal list : +plants => carnivorous plant, +plant spirit => + +dragon list : +wyvern => +real dragon => +draconoid (small dragons or manlike dragons who cannot talk) => +dracohuman (diluted blooded dragons with humans) => + +for cities towns and villages : +make dictionnaries with few characteristics, as name, country, continent, chief or mayor name, specialty (like a food, drink, type of cloth...)... +...environment type (when hardcoded - will see to use cardinal directions for procedurally generated ones, or select environmeent before to assign after)... +...type : village, town, city, or capital +make new lists in order to randomly assign those when procedurally generated +do double lists : one for only name, for story purposes ; the other for the entire definition and template + +************************************************************************* + +STATS : + +main : + +add char stats => strength, dexterity, agility, vitality, energy, luck => dictionary ? +add regeneration for life, stamina and mana, based on class or monster species/type +notes : +=> for certain monsters life regen is not 0 (vampire ?) +=> life regen might be negative for some undead + +secondary : + +speed +masteries : weapons, armors, magic + +derived : + +flee factor => from agility +power => strength + weapon mastery + wweapon damage + skills + bonus +defense => armor mastery + skills + bonus \ No newline at end of file diff --git a/src/__pycache__/database_connection.cpython-313.pyc b/src/__pycache__/database_connection.cpython-313.pyc new file mode 100644 index 0000000..cbaaf66 Binary files /dev/null and b/src/__pycache__/database_connection.cpython-313.pyc differ diff --git a/src/__pycache__/database_feed.cpython-313.pyc b/src/__pycache__/database_feed.cpython-313.pyc new file mode 100644 index 0000000..9d4c73b Binary files /dev/null and b/src/__pycache__/database_feed.cpython-313.pyc differ diff --git a/src/__pycache__/lists.cpython-313.pyc b/src/__pycache__/lists.cpython-313.pyc new file mode 100644 index 0000000..358a022 Binary files /dev/null and b/src/__pycache__/lists.cpython-313.pyc differ diff --git a/src/combat.py b/src/combat.py new file mode 100644 index 0000000..e69de29 diff --git a/src/database_connection.py b/src/database_connection.py index a4c4d00..1ae049e 100644 --- a/src/database_connection.py +++ b/src/database_connection.py @@ -1,2 +1,26 @@ import sqlite3 + +#Connection to database +def dbconnect(): + connection = sqlite3.connect('database/RPG_Database.db') + return connection +#Cursor declaration to feed database +def dbcursor(): + connection = dbconnect() + return connection.cursor() + +#In case of error in the except block +def dberror(error): + print("Error ", error) + dbConnect = dbconnect() + dbCursor = dbconnect() + dbConnect.rollback() + dbCursor.rollback() + +#And finally close all when done +def dbclose(): + connection = dbconnect() + cursor = dbcursor() + connection.close() + cursor.close() \ No newline at end of file diff --git a/src/database_feed.py b/src/database_feed.py new file mode 100644 index 0000000..d24246e --- /dev/null +++ b/src/database_feed.py @@ -0,0 +1,82 @@ +import random, math, sys +from database_connection import * + +try: + + #Database tables creation functions + def databaseSaves(): + + #Calling needed variables from databse connection file + connection = dbconnect() + cursor = dbcursor() + + #Create saves table + cursor.execute(""" + CREATE TABLE IF NOT EXISTS saves( + id INTEGER PRIMARY KEY AUTOINCREMENT UNIQUE, + characterName TEXT, + characterLevel INTEGER, + characterXP INTEGER + ) + """) + connection.commit() + + def databaseItems(): + pass + + def databaseWeapons(): + + #Calling needed variables from databse connection file + connection = dbconnect() + cursor = dbcursor() + + #Create weapons table + cursor.execute(""" + CREATE TABLE IF NOT EXISTS weapons( + id INTEGER PRIMARY KEY AUTOINCREMENT UNIQUE, + weaponName TEXT, + weaponType TEXT, + weaponRank TEXT, + weaponLevel INTEGER, + weaponPrice INTEGER + ) + """) + connection.commit() + + def databaseArmors(): + + #Calling needed variables from databse connection file + connection = dbconnect() + cursor = dbcursor() + + #Create armors table + cursor.execute(""" + CREATE TABLE IF NOT EXISTS armors( + id INTEGER PRIMARY KEY AUTOINCREMENT UNIQUE, + armorName TEXT, + armorType TEXT, + armorRank TEXT, + armorLevel INTEGER, + armorPrice INTEGER + ) + """) + connection.commit() + + def databasePotions(): + pass + + def databaseIngredients(): + pass + + def databaseMonsters(): + pass + + #Database tables update functions + def databaseSaveCreation(): + pass + +except Exception as error: + print("Error ", error) + +finally: + pass \ No newline at end of file diff --git a/src/death.py b/src/death.py new file mode 100644 index 0000000..e69de29 diff --git a/src/exploration.py b/src/exploration.py new file mode 100644 index 0000000..e69de29 diff --git a/src/game_master.py b/src/game_master.py new file mode 100644 index 0000000..24bec84 --- /dev/null +++ b/src/game_master.py @@ -0,0 +1,10 @@ +import random, math, sys + +try: + pass + +except Exception as error: + print("Error ", error) + +finally: + pass \ No newline at end of file diff --git a/src/lists.py b/src/lists.py new file mode 100644 index 0000000..4f94665 --- /dev/null +++ b/src/lists.py @@ -0,0 +1,567 @@ +import random, copy +from database_feed import * + +#This file will contain all items lists that will be needed for the game + +################################################################################################# +# GENERAL LISTS # +################################################################################################# + +speciesList = [] +mobList = [] +mobSpeciesList = [] + +jobList = [] +classList = [] + +continentNamesList = [] +countryNamesList = [] +allCitiesNamesList = [] +majorCitiesNamesList = [] +cityNamesList = [] +villageNamesList = [] + +continentList = [] +countryList = [] +allCitiesList = [] +majorCitiesList = [] +cityList = [] +villageList = [] + +environmentTypeList = [] + +#Assigning major cities to their country +cityDict = {} +#for of loop + +#Assigning countries to their continent +countryDict = {} +#for of loop + +originHumanList = [] +originMonsterList = [] + +mobPlainsList = [] +modPlainsFrequencyList = [] +mobPlainsDict = {} + +mobSavannaList = [] +modSavannaFrequencyList = [] +mobSavannaDict = {} + +mobForestList = [] +mobForestFrequencyList = [] +mobForestDict = {} + +mobCaveList = [] +mobCaveFrequencyList = [] +mobCaveDict = {} + +mobDesertList = [] +mobDesertFrequencyList = [] +mobDesertDict = {} + +mobSnowList = [] +mobSnowFrequencyList = [] +modSnowDict = {} + +mobMountainsList = [] +mobMountainsFrequencyList = [] +mobMountainsDict = {} + +mobRiverList = [] +mobRiverFrequencyList = [] +mobRiverDict = {} + +mobLakeList = [] +mobLakeFrequencyList = [] +mobLakeDict = {} + +mobSeaList = [] +mobSeaFrequencyList = [] +mobSeaDict = {} + +mobSkyList = [] +mobSkyFrequencyList = [] +mobSkyDict = {} + +#Append origin sublists in main lists and dictionaries +originHumanList.append(allCitiesList) +originHumanList.append(countryList) +originHumanList.append(continentList) +originMonsterList.append(environmentTypeList) + +allCitiesList.append(majorCitiesList) +allCitiesList.append(cityList) +allCitiesList.append(villageNamesList) + +originMonsterList.append(continentList) + +originHumanDict = { + 'City': cityList[0], + 'Country': countryList[0], + 'Continent': continentList[0] +} + +#Idea for the corresponding country and continent for each preceding entity +#make major cities correspond to a country, each country to a continent, then +#make the random choice catch the corresponding value and pass it to the dictionary + +originHumanRandomDict = { #make it so the country is corresponding + 'City': random.choice(allCitiesList), + 'Country': random.choice(countryList), + 'Continent': random.choice(continentList) +} + + #Characters + + #NPC human - major defined NPC only +humanList = [] + + #Monsters + #Species and Races + + #Humanoids +humanoidList = [] +corruptedHumanList = [] +corruptedElfList = [] +corruptedDwarfList = [] +beastMenList = [] +homonculiiList = [] +#Append in humanoids list +humanoidList.append(corruptedHumanList) +humanoidList.append(corruptedElfList) +humanoidList.append(corruptedDwarfList) +humanoidList.append(beastMenList) +humanoidList.append(homonculiiList) + + #Pseudohumanoids +pseudoHumanoidList = [] +goblinoidList = [] +orcoidList = [] +ogreList = [] +#Append in pseudohumanoids list +pseudoHumanoidList.append(goblinoidList) +pseudoHumanoidList.append(orcoidList) +pseudoHumanoidList.append(ogreList) + + #Undead - Humanoid +undeadHumanoidList = [] +vampireList = [] +zombieList = [] +skeletonList = [] +ghostList = [] +#Append in humanoid undead list +humanoidList.append(undeadHumanoidList) +undeadHumanoidList.append(vampireList) +undeadHumanoidList.append(zombieList) +undeadHumanoidList.append(skeletonList) +undeadHumanoidList.append(ghostList) + + #Undead - Non Humanoid +undeadList = [] +specterList = [] +#Append in non humanoid undead list +undeadList.append(specterList) + + #Demons +#Append in demons list + + #Slimy +slimyList = [] +slimelist = [] +mudList = [] +gelList = [] +#Append in slimy list +slimyList.append(slimelist) +slimyList.append(mudList) +slimyList.append(gelList) + + #Inhabited places - hardcoded => do procedurally generated ones later in definitions ? + + #Villages +villageNamesList.append("Slenia") + + #Cities and Towns + + #Main cities +majorCitiesNamesList.append("Otoria") + + #Dungeons - hardcoded base + + #Subterranean + + #Overworld + + #Air placed + + #Other dimensions + + #Dungeons - procedurally generated + procedural algorithm => TO DO later in definitions ? + + #Environement List +environmentTypeList.append("Plains") +environmentTypeList.append("Savanna") +environmentTypeList.append("Forest") +environmentTypeList.append("Cave") +environmentTypeList.append("Desert") +environmentTypeList.append("Snow") +environmentTypeList.append("Mountains") +environmentTypeList.append("River") +environmentTypeList.append("Lake") +environmentTypeList.append("Sea") +environmentTypeList.append("Sky") + + #Items + + #General items +itemList = [] + + #General categories +aidList = [] +weaponList = [] +armorList = [] + + #Precise categories + + #Weapons +swordList = [] +axeList = [] +spearList = [] +polearmList = [] +bowList = [] +crossbowList = [] + + + #Armors + + #Potions + +################################################################################################# +# GENERAL TEMPLATES # +################################################################################################# + + #Base global NPC Template +baseNPCTemplate = {} +baseNPCTemplate['LivingState'] = "Living" +baseNPCTemplate['Origin'] = "None" +baseNPCTemplate['Hostility'] = "Neutral" +baseNPCTemplate['Species'] = "Default" +baseNPCTemplate['Type'] = "Default" +baseNPCTemplate['Name'] = "Default" +baseNPCTemplate['Rank'] = 0 +baseNPCTemplate['Power'] = 0 +baseNPCTemplate['Defense'] = 0 +baseNPCTemplate['Life'] = 1 +baseNPCTemplate['MaxLife'] = 1 +baseNPCTemplate['LifeRegeneration'] = 0 +baseNPCTemplate['Stamina'] = 1 +baseNPCTemplate['MaxStamina'] = 1 +baseNPCTemplate['StaminaRegeneration'] = 2 +baseNPCTemplate['Mana'] = 0 +baseNPCTemplate['MaxMana'] = 0 +baseNPCTemplate['ManaRegeneration'] = 1 + +#Variables for XP and coins +valueFactorHuman = 20 +valueFactorMonster = 30 + + #Characters + + #Human NPC Base Template +baseHumanNPCTemplate = copy.deepcopy(baseNPCTemplate) +baseHumanNPCTemplate['Origin'] = originHumanList[0] +baseHumanNPCTemplate['Hostility'] = "Variable" +baseHumanNPCTemplate['Species'] = "Human" +baseHumanNPCTemplate['Type'] = "HumanRaceVarious" +baseHumanNPCTemplate['CoinFactorHuman'] = valueFactorHuman * 1.5 * baseHumanNPCTemplate['Rank'] +baseHumanNPCTemplate['CoinFactorArena'] = valueFactorHuman * 2.5 * (1 + baseHumanNPCTemplate['Rank']) +baseHumanNPCTemplate['CoinFactor'] = 0 +baseHumanNPCTemplate['XPHuman'] = valueFactorHuman * 1.2 * (1 + baseHumanNPCTemplate['Rank']) + + #Human in general context +generalHumanNPCTemplate = copy.deepcopy(baseHumanNPCTemplate) +generalHumanNPCTemplate['CoinFactor'] = generalHumanNPCTemplate['CoinFactorHuman'] + + #Human in arena context +arenaHumanNPCTemplate = copy.deepcopy(baseHumanNPCTemplate) +arenaHumanNPCTemplate['CoinFactor'] = arenaHumanNPCTemplate['CoinFactorArena'] + + + #Monster Base Template +baseMonsterTemplate = copy.deepcopy(baseNPCTemplate) +baseMonsterTemplate['Origin'] = originMonsterList[0] +baseMonsterTemplate['Hostility'] = "Hostile" +baseMonsterTemplate['Species'] = "Default" +baseMonsterTemplate['Type'] = "Monster" +baseMonsterTemplate['Rank'] = 1 +baseMonsterTemplate['CoinFactorSpecies'] = valueFactorMonster * 1.2 * baseMonsterTemplate['Rank'] +baseMonsterTemplate['CoinFactorType'] = valueFactorMonster * 1.4 * baseMonsterTemplate['Rank'] +baseMonsterTemplate['CoinFactor'] = 0 +baseMonsterTemplate['XP'] = valueFactorMonster * 1.3 * baseMonsterTemplate['Rank'] + + #Monsters species + + #Humanoids + + #Pseudo Humanoids + + #Monsters types + + #Humanoids +humanoidTemplate = copy.deepcopy(baseMonsterTemplate) +humanoidTemplate['Species'] = "Humanoid" + + #Pseudo Humanoids +pseudoHumanoidTemplate = copy.deepcopy(baseMonsterTemplate) +pseudoHumanoidTemplate['Species'] = "PseudoHumanoid" + + #Goblinoids +goblinTemplate = copy.deepcopy(pseudoHumanoidTemplate) +goblinTemplate['Type'] = "Goblinoid" +goblinTemplate['ManaRegeneration'] = 0 + + #Orcoids +orcTemplate = copy.deepcopy(pseudoHumanoidTemplate) +orcTemplate['Type'] = "Orcoid" +orcTemplate['ManaRegeneration'] = 0 + + #Ogre likes +ogreTemplate = copy.deepcopy(pseudoHumanoidTemplate) +ogreTemplate['Type'] = "OgreLike" +ogreTemplate['ManaRegeneration'] = 0 + + #Undead +undeadTemplate = copy.deepcopy(baseMonsterTemplate) +undeadTemplate['LivingState'] = "Undead" +undeadTemplate['ManaRegeneration'] = 0 + + #Vampires + #Zombies + #Skeletons + #Ghosts + #Other undead monsters - can be anything for particular situations + + #Slimy +slimyTemplate = copy.deepcopy(baseMonsterTemplate) +slimyTemplate['Species'] = "Slimy" +slimyTemplate['ManaRegeneration'] = 0 + + #Slimes +slimeTemplate = copy.deepcopy(slimyTemplate) +slimeTemplate['Type'] = "Slime" + + #Muddies - Muds +mudTemplate = copy.deepcopy(slimyTemplate) +mudTemplate['Type'] = "Mud" + + #Gels +gelTemplate = copy.deepcopy(slimyTemplate) +gelTemplate['Type'] = "Gel" + + #Pets + + #Base global inhabited places Template + + #Inhabited places - hardcoded +inhabitedPlaceTemplate = {} + + #Villages - Listing +villageTemplate = copy.deepcopy(inhabitedPlaceTemplate) + + #Cities and Towns - Listing + + #Main cities - Listing +majorCityTemplate = copy.deepcopy(inhabitedPlaceTemplate) + + #Dungeons - hardcoded base + + #Subterranean + + #Overworld + + #Air placed + + #Other dimensions + + #Dungeons - procedurally generated + procedural algorithm => TO DO later + + #Environment Types + + #General Template +environmentBaseTemplate = {} +environmentBaseTemplate['Type'] = "Default" +environmentBaseTemplate['WorldLocation'] = "CardinalPoint" +environmentBaseTemplate['Fauna'] = "CorrespondingList" +environmentBaseTemplate['DifficultyFactor'] = 0 + + #Plains + + #Savanna + + #Forest + + #Cave + + #Desert + + #Snow + + #Mountains + + #River + + #Lake + + #Sea + + #Sky + + +################################################################################################# +# DEFINITIONS # +################################################################################################# + + #Characters + + #Humans + + #Monsters + + #Humanoids + + #Pseudo Humanoids + + #Goblins + +goblin = copy.deepcopy(goblinTemplate) +goblin['Name'] = "Goblin" +goblin['Power'] = 12 +goblin['Defense'] = 2 +goblin['Life'] = 50 +goblin['MaxLife'] = 50 +goblin['Stamina'] = 10 +goblin['MaxStamina'] = 10 +goblin['XP'] = 10 +goblin['CoinFactorSpecies'] = 3 + +goblinoidList.append(goblin) +mobList.append(goblin) +mobCaveList.append(goblin) +mobForestList.append(goblin) + +hobgoblin = copy.deepcopy(goblinTemplate) +hobgoblin['Name'] = "Hobgoblin" +hobgoblin['Rank'] = 2 +hobgoblin['Power'] = 16 +hobgoblin['Defense'] = 4 +hobgoblin['Life'] = 60 +hobgoblin['MaxLife'] = 60 +hobgoblin['Stamina'] = 15 +hobgoblin['MaxStamina'] = 15 +hobgoblin['XP'] = 14 +hobgoblin['CoinFactorSpecies'] = 5 + +goblinoidList.append(hobgoblin) +mobList.append(hobgoblin) +mobCaveList.append(hobgoblin) +mobForestList.append(hobgoblin) + + #Orcoids + + #Ogre likes + + #Undead + + #Vampires + #Zombies + #Skeletons + #Ghosts +ghost = copy.deepcopy(undeadTemplate) + +undeadHumanoidList.append(ghost) +mobList.append(ghost) #continue to append to other lists + + #Other undead monsters - can be anything for particular situations +specter = copy.deepcopy(undeadTemplate) + +undeadList.append(specter) +mobList.append(specter) #continue to append in other lists + + #Slimy + + #Slimes + +slime = copy.deepcopy(slimeTemplate) +slime['Name'] = "Slime" +slime['Power'] = 1 +slime['Defense'] = 0 +slime['Life'] = 4 +slime['MaxLife'] = 4 +slime['Stamina'] = 4 +slime['MaxStamina'] = 4 +slime['XP'] = 1 +slime['CoinFactorSpecies'] = 0.5 + +slimelist.append(slime) +mobList.append(slime) +mobCaveList.append(slime) +mobPlainsList.append(slime) + + #Muddies - Muds + #Gels + + #Pets + + #Base global inhabited places Template + + #Inhabited places - hardcoded + + #Villages - Listing +villageSlenia = copy.deepcopy(villageTemplate) + + #Cities and Towns - Listing + + #Main cities - Listing +majorCitiesOtoria = copy.deepcopy(majorCityTemplate) + + #Dungeons - hardcoded base + + #Subterranean + + #Overworld + + #Air placed + + #Other dimensions + + #Dungeons - procedurally generated + procedural algorithm => TO DO later + + #Environment Names - Example : "Plains of Skaria" can be Plains or other type + + #Plains + + #Savanna + + #Forest + + #Cave + + #Desert + + #Snow + + #Mountains + + #River + + #Lake + + #Sea + + #Sky + +################################################################################################# +# DICTIONARIES REFORMING # +################################################################################################# + diff --git a/src/testrpg.py b/src/main_script.py similarity index 79% rename from src/testrpg.py rename to src/main_script.py index a9c9931..f0102e8 100644 --- a/src/testrpg.py +++ b/src/main_script.py @@ -1,73 +1,16 @@ -import random, math, sys, sqlite3 +import random, math, sys +from database_connection import dbconnect, dbcursor, dberror, dbclose +from database_feed import * try: - #Connection to database - connection = sqlite3.connect('database/RPG_Database.db') - cursor = connection.cursor() - #Database tables creation functions - def databaseSaves(): - - #Create saves table - cursor.execute(""" - CREATE TABLE IF NOT EXISTS saves( - id INTEGER PRIMARY KEY AUTOINCREMENT UNIQUE, - characterName TEXT, - characterLevel INTEGER, - characterXP INTEGER - ) - """) - connection.commit() - - def databaseItems(): - pass - - def databaseWeapons(): - - #Create weapons table - cursor.execute(""" - CREATE TABLE IF NOT EXISTS weapons( - id INTEGER PRIMARY KEY AUTOINCREMENT UNIQUE, - weaponName TEXT, - weaponType TEXT, - weaponRank TEXT, - weaponLevel INTEGER, - weaponPrice INTEGER - ) - """) - connection.commit() - - def databaseArmors(): - - #Create armors table - cursor.execute(""" - CREATE TABLE IF NOT EXISTS armors( - id INTEGER PRIMARY KEY AUTOINCREMENT UNIQUE, - armorName TEXT, - armorType TEXT, - armorRank TEXT, - armorLevel INTEGER, - armorPrice INTEGER - ) - """) - connection.commit() - - def databasePotions(): - pass - - def databaseIngredients(): - pass - - def databaseMonsters(): - pass + dbconnect() + dbcursor() - #Database tables update functions - def databaseSaveCreation(): - pass - - #Global check variable + #Global check variables characterCheck = False combatCheck = False + explorationCheck = False playCheck = True villageCheck = True dungeonCheck = True @@ -205,6 +148,108 @@ def death(): print("Not a good choice") #Death function end + #Exploration function + def explorationLoop(character): + + #Global variables + global explorationCheck + global player + + #Initializing player variable + player = character + + while explorationCheck == True: + + #Initializing random numbers for events purpose + explorationRandom = random.randint(0, 5) + + #Declare variables for exploration + choice = 0 + explo = 1 + explorationRandom + + if explo == 1: + #Find an item + print("You stumble upon an item on the floor, what is that ?") + #make lists : + #one list for all item where the only property is type : weapon, armor, aid... + #another one for each item type with according properties + choice = int(input("Continue exploring (1) or go out (2) ?\n")) + if choice == 1: + explorationLoop(player) + elif choice == 2: + explorationCheck = False + village() + else: + explorationCheck = False + village() + elif explo == 2: + #Monster ambush + monster = random.choice(mobList).copy() + print("You are ambushed by a ", monster['Name'], " !") + combatLoop(player, monster) + choice = int(input("Continue exploring (1) or go out (2) ?\n")) + if choice == 1: + explorationLoop(player) + elif choice == 2: + explorationCheck = False + village() + else: + explorationCheck = False + village() + elif explo == 3: + #See a monster from a distance + monster = random.choice(mobList).copy() + print("You see a monster, but it does not seem to see you, it appears to be a ", monster['Name']) + choice = int(input("Do you wish to fight this ", monster['Name'], " Yes (1), No (2) ?")) + if choice == 1: + combatLoop(player, monster) + elif choice == 2: + choice = int(input("Continue exploring (1) or go out (2) ?\n")) + if choice == 1: + explorationLoop(player) + elif choice == 2: + explorationCheck = False + village() + else: + explorationCheck = False + village() + else: + print("Wrong choice, continuig exploration...") + explorationLoop(player) + elif explo == 4: + choice = int(input("Continue exploring (1) or go out (2) ?\n")) + if choice == 1: + explorationLoop(player) + elif choice == 2: + explorationCheck = False + village() + else: + explorationCheck = False + village() + elif explo == 5: + choice = int(input("Continue exploring (1) or go out (2) ?\n")) + if choice == 1: + explorationLoop(player) + elif choice == 2: + explorationCheck = False + village() + else: + explorationCheck = False + village() + elif explo == 6: + choice = int(input("Continue exploring (1) or go out (2) ?\n")) + if choice == 1: + explorationLoop(player) + elif choice == 2: + explorationCheck = False + village() + else: + explorationCheck = False + village() + + + #Exploration function end + #Combat function def combatLoop(character, monster): @@ -559,6 +604,11 @@ def church(): village() #Church end + #Resurrection function + def resurrection(character): + pass + #End of resurrection function + #Function for rumors def rumors(): pass @@ -574,9 +624,27 @@ def rest(): pass #Rest end + #Dungeon function + def exploration(character): + + #Resetting global combat checker + global explorationCheck + explorationCheck = True + + while explorationCheck == True: + exploration(character) + + return character + + #Dongeon function end + #Dungeon function def dungeon(character): + #Resetting global combat checker + global combatCheck + combatCheck = False + while combatCheck == False: combatLoop(character, mobList) @@ -614,6 +682,7 @@ def welcome(): def game(): #Call database functions + #put these in a conditional choice depending on if they have been made or not within the save file databaseSaves() databaseWeapons() databaseArmors() @@ -638,7 +707,8 @@ def game(): if choice == 1: village() elif choice == 2: - pass + print("You go for a little tour around the plains...") + exploration(character) elif choice == 3: print("Be cautious exploring the dungeon...") dungeon(character) @@ -657,8 +727,7 @@ def game(): game() except Exception as error: - print("Error ", error) - connection.rollback() + dberror(error) finally: - connection.close() \ No newline at end of file + dbclose() \ No newline at end of file diff --git a/src/rpg-complex.py b/src/rpg-complex.py deleted file mode 100644 index 5efdd2a..0000000 --- a/src/rpg-complex.py +++ /dev/null @@ -1,228 +0,0 @@ -import math, random - -class Character: - - #Main Class for specifying character types - kind = "character"; - - #Name placeholder - name = ""; - weapon = ""; - - #Define character - def __init__(self): - pass; - - def stats (self, levelFixed, healthMax, healthCurrent, stamina, mana, power, defense, block, xpPoints): - self.levelFixed = self.stats['levelFixed']; - self.healthMax = healthMax; - self.healthCurrent = healthCurrent; - self.stamina = stamina; - self.mana = mana; - self.power = power; - self.defense = defense; - self.block = block; - self.xpPoints = xpPoints; - -class PlayerCharacter(Character): - - #Player character type - kind = "player character"; - - #Initialize level and experience - xp = 0; - level = 1; - - #Initialize player - def __init__(self, name, weapon): - self.name = name; - self.weapon = weapon; - self.inventory = []; - - def levelup(self): - self.level += 1; - print("\n**~~~~**\nLEVEL UP ! Welcome to level {}\n**~~~~**\n".format(self.level)); - - - -class NonPlayerCharacter(Character): - - #Non player character type - kind = "non player character"; - - def __init__(self): - pass; - -class Villager(NonPlayerCharacter): - - #Villager type for non mob example - kind = "villager"; - - def __init__(self): - pass; - -class Mob(NonPlayerCharacter): - - #Mob type - kind = "Mob"; - - def __init__(self): - pass; - -class PassiveMob(Mob): - - #Passive mob type = animal - kind = "animal"; - - def __init__(self): - pass; - -class NeutralMob(Mob): - - #Passive mob type = beast - kind = "beast"; - - def __init__(self): - pass; - -class HostileMob(Mob): - - #Hostile mob type = monster - kind = "hostile"; - - #Define monster - def __init__(self): - pass; - -#Define a player variable to initialize -def player(): - PlayerCharacter(str(input("Choose name")), 1, 100, 100, 100, 100, 1, 1, 0, 0); - -#Initialize few mobs for combat -goblin = HostileMob('Goblin', 'Goblinoid', 1, 10, 10, 5, 0, 1, 1, 0, 3); -slime = HostileMob('Slime', 'Slimy', 1, 1, 1, 0, 0, 1, 0, 0, 1); -orc = HostileMob('Orc', 'Goblinoid', 1, 20, 20, 10, 0, 3, 1, 0, 7); - -#List for storing hostile mob and randomly choose in combat -mobList = []; - -#Pushing mobs into list -mobList.append(goblin, slime, orc); - -class GameElements: - - #Combat Loop function - def combatLoop(self, player, mob): - - #Global Class variables - player = playerGlobal; - mob = random.choice(mobList); - xp = 0; - - #Declare monster randomly chosen - mob = random.choice(mobList); - - #Declare variables for choice and combat check - choice = 0; - combatCheck = False; - damage = 0; - - #Random number to decide monster flee - fleeRandom = random.randint(0, 99); - - #Storage variable for save purpose - basePower = player.power; - baseDefense = player.defense; - baseBlock = player.block; - - while combatCheck == False and mob.healthCurrent > 0 and player.healthCurrent > 0: - - #Giving values for heads up - print("Your health : {player.healthCurrent}\nMob health : {mob.healthCurrent}"); - print("Your stamina : {player.stamina}\nYour mana : {player.mana}") - - #Indicating player turn - print("Player turn :"); - int(input("What do you want to do ?\nAttack : 1\nHeal : 2\nDefend : 3\nFlee : 4")); - - #Each turn reinitialize values - player.power = basePower; - player.defense = baseDefense; - player.block = baseBlock; - - #Decision tree for player turn - if choice == 1: #attack - mob.healthCurrent -= player.power; - print("Inflicted {player.power} damage"); - print(mob.healthCurrent); - elif choice == 2: #heal - #Condition = player have lost health or not - if player.healthCurrent < player.healthMax: - healthReceived = min((player.healthCurrent + player.power - player.healthMax), player.power); - player.healthCurrent = min((player.healthCurrent + player.power), player.healthMax); - print("You healed yourself for {healthReceived} points"); - else: - print("You cannot heal yourself if you have taken no damage !"); - elif choice == 3: #defend - print("You chose defense, gained + 50% defense for one turn"); - player.defense *= 1.5; - elif choice == 4: #flee - print("Try to flee !"); - combatCheck = True; - break; - else: - print("Not a suitable choice"); - continue; - - #Indicating mob turn - print("Enemy turn :"); - - #Mob decision tree - if mob.healthCurrent > (round(mob.healthMax/2)): - print("Mob attacks !"); - damage = mob.power - player.defense; - player.healthCurrent = max((player.healthCurrent - damage), 1); - else: - if mob.healthCurrent > (mob.healthMax/4): - if fleeRandom > 50: - print("Mob attacks !"); - damage = mob.power - player.defense; - player.healthCurrent = max((player.healthCurrent - damage), 1); - else: - print("Monster flees !"); - combatCheck = True; - break; - elif mob.healthCurrent < (mob.healthMax/4): - if fleeRandom > 75: - print("Mob attacks !"); - damage = mob.power - player.defense; - player.healthCurrent = max((player.healthCurrent - damage), 1); - else: - print("Monster flees !"); - combatCheck = True; - break; - #Loop resumes - - - def drop(self): - - #Item list - items = []; - - def inventory(self): - #Inventory table - inventory = []; - -class Master: - - #Master function in Master Class - def master(self): - - #Global Class variables - player = playerGlobal; - mob = random.choice(mobList); - - #Call function - GameElements.combatLoop(player, mob); - - master(); \ No newline at end of file diff --git a/src/rpg-simple.py b/src/test_script.py similarity index 57% rename from src/rpg-simple.py rename to src/test_script.py index cadf712..010c430 100644 --- a/src/rpg-simple.py +++ b/src/test_script.py @@ -1,138 +1,96 @@ -import random, math, sys, sqlite3 +import random, math, sys, copy +from database_connection import dbconnect, dbcursor, dberror, dbclose +from database_feed import * +from lists import * try: - #Connection to database - connection = sqlite3.connect('database/RPG_Database.db') - cursor = connection.cursor() - #Database tables creation functions - def databaseSaves(): - - #Create saves table - cursor.execute(""" - CREATE TABLE IF NOT EXISTS saves( - id INTEGER PRIMARY KEY AUTOINCREMENT UNIQUE, - characterName TEXT, - characterLevel INTEGER, - characterXP INTEGER - ) - """) - connection.commit() - - def databaseItems(): - pass + dbconnect() + dbcursor() - def databaseWeapons(): - - #Create weapons table - cursor.execute(""" - CREATE TABLE IF NOT EXISTS weapons( - id INTEGER PRIMARY KEY AUTOINCREMENT UNIQUE, - weaponName TEXT, - weaponType TEXT, - weaponRank TEXT, - weaponLevel INTEGER, - weaponPrice INTEGER - ) - """) - connection.commit() - - def databaseArmors(): - - #Create armors table - cursor.execute(""" - CREATE TABLE IF NOT EXISTS armors( - id INTEGER PRIMARY KEY AUTOINCREMENT UNIQUE, - armorName TEXT, - armorType TEXT, - armorRank TEXT, - armorLevel INTEGER, - armorPrice INTEGER - ) - """) - connection.commit() - - def databasePotions(): - pass - - def databaseIngredients(): - pass - - def databaseMonsters(): - pass - - #Database tables update functions - def databaseSaveCreation(): - pass - - #Global check variable + #Global check variables + characterCheck = False combatCheck = False + explorationCheck = False playCheck = True villageCheck = True dungeonCheck = True + player = {} + character = {} #Player character - player = {} - player['Name'] = str(input("Enter your name\n")) - - print("So you are called ", player['Name']) - - player['Inventory'] = [] - - player['Coins'] = 0 - player['XP'] = 0 - player['Level'] = 1 - player['Power'] = 1 - player['Defense'] = 0 - player['Armor'] = "" - player['ArmorDefense'] = 0 - player['Avoid'] = 0 - player['Life'] = 100 - player['MaxLife'] = 100 - player['Mana'] = 0 - player['MaxMana'] = 0 - player['Stamina'] = 50 - player['MaxStamina'] = 50 - player['XP'] = 0 - player['Level'] = 1 - player['Weapon'] = "" - player['WeaponDamage'] = 0 - player['DamageBonus'] = 0 - player['DefenseBonus'] = 0 - player['ClassChoice'] = int(input("Choose your class : 1 for Swordmaster, 2 for Warrior, 3 for Knight, 4 for Archer\n")) - - #Weapon choice - if player['ClassChoice'] == 1: - player['Weapon'] = "Sword" - player['Armor'] = "Leather Armor" - player['WeaponDamage'] = 8 - player['ArmorDefense'] = 8 - player['Avoid'] = 10 - print("You have equipped a sword and a leather armor, you have 10% chance to avoid\n") - elif player['ClassChoice'] == 2: - player['Weapon'] = "Axe" - player['Armor'] = "Iron Armor" - player['WeaponDamage'] = 16 - player['ArmorDefense'] = 16 - print("You have equipped an axe and an iron armor\n") - elif player['ClassChoice'] == 3: - player['Weapon'] = "Spear" - player['Armor'] = "Boiled Leather Armor" - player['WeaponDamage'] = 12 - player['ArmorDefense'] = 12 - print("You have equipped a spear and a boiled leather armor\n") - elif player['ClassChoice'] == 4: - player['Weapon'] = "Bow" - player['Armor'] = "Cloth Armor" - player['WeaponDamage'] = 6 - player['Avoid'] = 30 - print("You have equipped a bow and a cloth armor, you have 0 armor but 30% chance to avoid\n") - else: - print("Pass here") #Debug - pass + def characterCreation(): + + #Character creation checker + global characterCheck + global player + + #Player creation + player = {} + player['Name'] = str(input("What's your name ?\n")) + + print("So you are called ", player['Name'], ", nice name !") + + player['Inventory'] = [] + + player['Coins'] = 0 + player['XP'] = 0 + player['Level'] = 1 + player['Power'] = 1 + player['Defense'] = 0 + player['Armor'] = "" + player['ArmorDefense'] = 0 + player['Avoid'] = 0 + player['Life'] = 100 + player['MaxLife'] = 100 + player['Mana'] = 0 + player['MaxMana'] = 0 + player['Stamina'] = 50 + player['MaxStamina'] = 50 + player['XP'] = 0 + player['Level'] = 1 + player['Weapon'] = "" + player['WeaponDamage'] = 0 + player['DamageBonus'] = 0 + player['DefenseBonus'] = 0 + player['ClassChoice'] = int(input("What are you ? Swordmaster (1), Warrior (2), Knight (3), Archer (4)\n")) + + #Class and equipment choice + if player['ClassChoice'] == 1: + player['Weapon'] = "Sword" + player['Armor'] = "Leather Armor" + player['WeaponDamage'] = 8 + player['ArmorDefense'] = 8 + player['Avoid'] = 10 + print("You have equipped a sword and a leather armor, you have 10% chance to avoid\n") + elif player['ClassChoice'] == 2: + player['Weapon'] = "Axe" + player['Armor'] = "Iron Armor" + player['WeaponDamage'] = 16 + player['ArmorDefense'] = 16 + print("You have equipped an axe and an iron armor\n") + elif player['ClassChoice'] == 3: + player['Weapon'] = "Spear" + player['Armor'] = "Boiled Leather Armor" + player['WeaponDamage'] = 12 + player['ArmorDefense'] = 12 + print("You have equipped a spear and a boiled leather armor\n") + elif player['ClassChoice'] == 4: + player['Weapon'] = "Bow" + player['Armor'] = "Cloth Armor" + player['WeaponDamage'] = 6 + player['Avoid'] = 30 + print("You have equipped a bow and a cloth armor, you have 0 armor but 30% chance to avoid\n") + else: + print("Pass here") #Debug + pass + + characterCheck = True + village() + + return player #Define monsters - mobList = [] goblin = {} goblin['Type'] = "Goblinoid" @@ -144,7 +102,7 @@ def databaseSaveCreation(): goblin['XP'] = 10 goblin['CoinFactor'] = 3 - mobList.append(goblin) + #mobList.append(goblin) hobgoblin = {} hobgoblin['Type'] = "Goblinoid" @@ -156,7 +114,7 @@ def databaseSaveCreation(): hobgoblin['XP'] = 14 hobgoblin['CoinFactor'] = 5 - mobList.append(hobgoblin) + #mobList.append(hobgoblin) slime = {} slime['Type'] = "Slimy" @@ -179,9 +137,9 @@ def levelUp(): #Death function def death(): print("You died...") - choice = int(input("Wiuld you like to resurrect in the village church ? 1 for yes, 0 for no")) + choice = int(input("Would you like to resurrect in the village church ? 1 for yes, 0 for no")) if choice == 1: - pass #resurrect + pass #resurrect() elif choice == 2: print("You died for good... the character will be deleted...") #call delete function for char db @@ -190,15 +148,121 @@ def death(): print("Not a good choice") #Death function end + #Exploration function + def explorationLoop(character): + + #Global variables + global explorationCheck + global player + + #Initializing player variable + player = character + + while explorationCheck == True: + + #Initializing random numbers for events purpose + explorationRandom = random.randint(0, 5) + + #Declare variables for exploration + choice = 0 + explo = 1 + explorationRandom + + if explo == 1: + #Find an item + print("You stumble upon an item on the floor, what is that ?") + #make lists : + #one list for all item where the only property is type : weapon, armor, aid... + #another one for each item type with according properties + choice = int(input("Continue exploring (1) or go out (2) ?\n")) + if choice == 1: + explorationLoop(player) + elif choice == 2: + explorationCheck = False + village() + else: + explorationCheck = False + village() + elif explo == 2: + #Monster ambush + monster = random.choice(mobList).copy() + print("You are ambushed by a ", monster['Name'], " !") + combatLoop(player, monster) + choice = int(input("Continue exploring (1) or go out (2) ?\n")) + if choice == 1: + explorationLoop(player) + elif choice == 2: + explorationCheck = False + village() + else: + explorationCheck = False + village() + elif explo == 3: + #See a monster from a distance + monster = random.choice(mobList).copy() + print("You see a monster, but it does not seem to see you, it appears to be a ", monster['Name']) + choice = int(input("Do you wish to fight this ", monster['Name'], " Yes (1), No (2) ?")) + if choice == 1: + combatLoop(player, monster) + elif choice == 2: + choice = int(input("Continue exploring (1) or go out (2) ?\n")) + if choice == 1: + explorationLoop(player) + elif choice == 2: + explorationCheck = False + village() + else: + explorationCheck = False + village() + else: + print("Wrong choice, continuig exploration...") + explorationLoop(player) + elif explo == 4: + choice = int(input("Continue exploring (1) or go out (2) ?\n")) + if choice == 1: + explorationLoop(player) + elif choice == 2: + explorationCheck = False + village() + else: + explorationCheck = False + village() + elif explo == 5: + choice = int(input("Continue exploring (1) or go out (2) ?\n")) + if choice == 1: + explorationLoop(player) + elif choice == 2: + explorationCheck = False + village() + else: + explorationCheck = False + village() + elif explo == 6: + choice = int(input("Continue exploring (1) or go out (2) ?\n")) + if choice == 1: + explorationLoop(player) + elif choice == 2: + explorationCheck = False + village() + else: + explorationCheck = False + village() + + + #Exploration function end + #Combat function - def combatLoop(monster): + def combatLoop(character, monster): + + #Global variables + global combatCheck + global player - #Initializing enemy variable + #Initializing enemy variables monster = random.choice(mobList) enemy = monster.copy() - #Combat checker variable - global combatCheck + #Initializing player variable + player = character #Storage variable for save purpose basePower = player['Power'] @@ -255,7 +319,7 @@ def combatLoop(monster): print("You chose defense, gained + 50% defense for one turn") print("debug defense :", playerProtection) elif choice == 4: #flee - print("Try to flee !") + print("You flee !") combatCheck = True break @@ -298,21 +362,34 @@ def combatLoop(monster): player['Life'] = max((player['Life'] - monsterDamage), 0) else: monsterDamage = 0 - print("You avoided the attack") + print("You avoided the attack !") else: #Mob successfully flees, combat ends print("The ", enemy['Name'], " flees !") combatCheck = True break - else: + elif enemy['Life'] <= 0: #If enemy dies exit system and indicate to player print("You have vanquished the enemy") combatCheck = True - player['XP'] += goblin['XP'] - print("You have gained ", int(enemy['XP']), " XP points, and have ", int(player['XP']), " XP points") + player['XP'] += enemy['XP'] + print("You have gained ", int(enemy['XP']), " XP points, and have ", int(player['XP']), " XP points.") gainedCoins = 1 + round(coinsRandom * enemy['CoinFactor']) player['Coins'] += gainedCoins - print("You also gained ", gainedCoins, " coins !" ) + print("You also gained ", gainedCoins, " coins for a total of ", player['Coins'], " coins !" ) + + #Loop relaunch on order by the player + print("You may continue to explore the dungeon.") + choice = int(input("Continue exploring (1) or go out (2) ?\n")) + if choice == 1: + print("You continue exploring a little more...") + combatCheck = False + player = dungeon(player) + elif choice == 2: + print("You prefer to exit the dungeon for a while...") + game() + combatCheck = False + player = dungeon(player) #Loop resumes @@ -329,8 +406,11 @@ def village(): #Choice variable choice = 0 + villageCheck = True + while villageCheck == True: - choice = int(input("What do you want to do in the village ? 1 to shop, 2 to go to the tavern, 3 to go to the guild, 4 to go to the church, 0 to quit")) + print("What do you want to do in the village ?") + choice = int(input(" Shop (1), Tavern (2), Guild (3), Church (4), Exit (0)\n")) #Village - player decision tree if choice == 1: @@ -349,15 +429,14 @@ def village(): church() elif choice == 0: #Chose to quit village - print("Exciting village...") + print("Exiting village...") villageCheck = False - #Village function end #Village shops function def shops(): print("What shop do you want to visit ?") - choice = int(input("Available shops are : Armory (1), Jewelry (2), Alchemist (3), General store (4), Exit (0)")) + choice = int(input("Available shops are : Armory (1), Jewelry (2), Alchemist (3), General store (4), Exit (0)\n")) if choice == 1: #Visit armory armory() @@ -382,7 +461,7 @@ def shops(): #Function for armory def armory(): - choice = int(input("Do you want to buy (1) or sell (2) ? 0 to quit")) + choice = int(input("Do you want to buy (1) or sell (2) ? 0 to quit\n")) if choice == 1: pass #buy elif choice == 2: @@ -395,7 +474,7 @@ def armory(): #Function for jewelry def jewelry(): - choice = int(input("Do you want to buy (1) or sell (2) ? 0 to quit")) + choice = int(input("Do you want to buy (1) or sell (2) ? 0 to quit\n")) if choice == 1: pass #buy elif choice == 2: @@ -408,7 +487,7 @@ def jewelry(): #Function for alchemist def alchemist(): - choice = int(input("Do you want to heal (1), buy (2) or sell (3) ? 0 to quit")) + choice = int(input("Do you want to heal (1), buy (2) or sell (3) ? 0 to quit\n")) if choice == 1: pass #heal elif choice == 2: @@ -423,7 +502,7 @@ def alchemist(): #Function for general store def generalStore(): - choice = int(input("Do you want to buy (1) or sell (2) ? 0 to quit")) + choice = int(input("Do you want to buy (1) or sell (2) ? 0 to quit\n")) if choice == 1: pass #buy elif choice == 2: @@ -436,7 +515,7 @@ def generalStore(): #Function for tavern def tavern(): - choice = int(input("You can : Listen to rumors (1), Shop for food (2), Rent a room (3), Exit (0)")) + choice = int(input("You can : Listen to rumors (1), Shop for food (2), Rent a room (3), Exit (0)\n")) if choice == 1: #Chose rumors rumors() @@ -445,7 +524,7 @@ def tavern(): foodShop() elif choice == 3: #Chose rest - all stats are regen to max 75% - choice = int(input("Rest effectivness is 75% max, do you want to rent the room (1 yes or 0 no) ?")) + choice = int(input("Rest effectivness is 75% max, do you want to rent the room (1 yes or 0 no) ?\n")) if choice == 1: rest() elif choice == 0: @@ -465,7 +544,7 @@ def tavern(): #Function for food shopping def foodShop(): - choice = int(input("Do you want to buy (1) or sell (2) ? Exit (0)")) + choice = int(input("Do you want to buy (1) or sell (2) ? Exit (0)\n")) if choice == 1: pass #buy food elif choice == 2: @@ -478,7 +557,7 @@ def foodShop(): #Function for the guild def guild(): - choice = int(input("Available services are : Look for quests (1), Shop for food (2), Go to your room (3), Talk with people (4), Exit (0)")) + choice = int(input("Available services are : Look for quests (1), Shop for food (2), Go to your room (3), Talk with people (4), Exit (0)\n")) if choice == 1: #Chose quests print("What quests are available... ?") @@ -500,7 +579,7 @@ def guild(): #Function for church def church(): print("Welcome to the church, what do you want to do ?") - choice = int(input("We offer those services : 1 to pray a god, 2 to receive a boon, 3 to remove a curse, 4 to buy holy water, 5 to save, 0 to quit")) + choice = int(input("We offer those services : Pray to a god (1), Receive a boon (2), Remove a curse (3), Buy holy water (4), Save (5), Exit (0)\n")) if choice == 1: #Chose prayer print("What god to pray... ?") @@ -511,6 +590,12 @@ def church(): elif choice == 3: #Chose curse removal pass #call curseRemoval() + elif choice == 4: + #Chose buy holy water + pass #call buyHolyWater() + elif choice == 5: + #Chose save + pass #call saveGame() elif choice == 0: pass #quit shopping village() @@ -519,6 +604,11 @@ def church(): village() #Church end + #Resurrection function + def resurrection(character): + pass + #End of resurrection function + #Function for rumors def rumors(): pass @@ -535,10 +625,30 @@ def rest(): #Rest end #Dungeon function - def dungeon(): - while player['Life'] > 0 and combatCheck == False: - combatLoop(mobList) + def exploration(character): + + #Resetting global combat checker + global explorationCheck + explorationCheck = True + + while explorationCheck == True: + exploration(character) + + return character + + #Dongeon function end + + #Dungeon function + def dungeon(character): + #Resetting global combat checker + global combatCheck + combatCheck = False + + while combatCheck == False: + combatLoop(character, mobList) + + return character #Dongeon function end @@ -547,30 +657,61 @@ def options(): pass #call delete or other db functions #Options end + #Function to welcome player + def welcome(): + + choice = int(input("Welcome to the Elder Stones game, do you want to create a new character (1) or load an existing one (2) ? Use 0 to quit game !\n")) + + if choice == 1: + #Create a character + print("So you're a new adventurer here. How about you ? Give us some details about yourself.") + character = characterCreation() + elif choice == 2: + #character = db character + pass #load char from save + elif choice == 0: + print("Quitting game...") + sys.exit() + else: + print("Wrong choice, quitting game...") + sys.exit() + + return character + + #Welcome end def game(): #Call database functions + #put these in a conditional choice depending on if they have been made or not within the save file databaseSaves() databaseWeapons() databaseArmors() #Play checker variable global playCheck + global character + global characterCheck #Choice variable choice = 0 + #Call welcome function + if characterCheck == False: + character = welcome() + characterCheck = True + #Game loop while playCheck == True: print("What do you want to do ?") choice = int(input("Enter village (1), Explore surroundings (2), Explore dungeon (3), Additional options (4), Quit game (0)\n")) if choice == 1: - while villageCheck == True: - village() + village() elif choice == 2: - pass + print("You go for a little tour around the plains...") + exploration(character) elif choice == 3: - dungeon() + print("Be cautious exploring the dungeon...") + dungeon(character) elif choice == 4: pass #delete save, modify settings, other things options() @@ -586,8 +727,7 @@ def game(): game() except Exception as error: - print("Error ", error) - connection.rollback() + dberror(error) finally: - connection.close() \ No newline at end of file + dbclose() \ No newline at end of file diff --git a/src/village.py b/src/village.py new file mode 100644 index 0000000..e69de29