MIPYTHON com | Dungeons and Dragons Random Character and Combat Bot

2018 agent automation baby best Bot cash chat chatbot cpu crypto currency detroit flint free gpu JAVA PYTHON WRAPPER MICHIGAN miner mining monero SEO virtual virtual agent watson xmr z zcash zec

A long time project of mine came to fruition for a few hours this morning. It is not even close to being done or even alpha at this stage.  I’ve always wanted to make a Dungeons and Dragons inspired Text Adventure Game.  Now this frame work done in pure Python is still very rudimentary.  I’m still just learning.  I also only had a few hours to revision this long time dream of coding my very own Dungeons and Dragons Random Character and Combat Bot in pure Python.  Just a sneak peak it’s not done yet…

MIPYTHON com | Dungeons and Dragons Random Character and Combat Bot

This is Pure Python here so no external modules besides Random.  First were gonna import random

<pre lang=”python”> import random </pre>

Then lets define our classes for both a Character and a Rolling System.  I’m still just learning. I Thought this would be a fun way of learning to pass a variable between two classes.

First our Character Class.

 
class character(object):
 
     def __init__(self,name,intro,initiative,movement,attack,defense,damage,hitpoints):
        self.name = name
        self.intro = intro
        self.initiative = initiative
        self.movement = movement
        self.attack = attack
        self.defense = defense
        self.damage = damage
        self.hitpoints = hitpoints
 
 
 
     def main(self):
 
        pass
 
     def initiative_roll(self):
        space = "  "
        self.initiative = self.initiative + random.randint(1,10)
        print(self.name + space + "Initative Roll:")
        print("Rolls: % for Initiative") % self.initiative
        return self.initiative
 
     def move_roll(self):
        space = "  "
        self.movement = (self.movement) + random.randint(1,10)
        print(self.name + space + "Move Roll:")
        print(self.name + "Rolls: " + space + str(self.movement))
        #print(self.movement) #% self.movement
        #return str(self.name) + " Moves :  "
        return self.movement
 
     def attack_roll(self):
 
        space = "  "
        self.attack = self.attack + random.randint(1,99)
        #print("\n Rolls a % To Attack!") % int(self.attack) + random.randint(0,10)
        #return int(self.attack) + random.randint(0,10)
        #print(self.name + "Moves : " + self.movement )
        #print(self.name + "Rolls For Attack:")
        print(self.name + space + "Attack Roll:")
        print(self.name)
        print("Rolls: %" + space + " for Attack") % self.attack
        return self.attack
 
     def defense_roll(self):
        space = "  "
        self.defense = self.defense + random.randint(1,99)
        print(self.name + space + "Defense Roll:")
        print(self.name)
        print("Rolls: % for Defense") % self.defense
        #print(self.defense)
        return self.defense
 
     def damage_roll(self):
        return self.damage

 

The above Character Class just defines generic : Character Name, Introduction, Initiative Roll, Movement Roll, Attack Roll, Defense Roll, Damage and Hitpoint Variables.  I’m not sure of the best practice to go about this yet so bear with me.  I just used different functions within the Class to take the Characters Roll and pass it down to the Roll System Class below.  Maybe all the variables are redundant?  They can be modified later when the Class is Instantiated.  For now just to keep things simple every thing is based off of 1 – 100 or 1-10 Random number generation.  Here’s the Roll System Class.

class roll_system(object):
 
     def __init__(self):
        pass
        #self.combat_resolving = combat_resolving
        #self.wound_handeling = wound_handeling
 
     def main(self):
        pass
 
     def combat_system(self):
        #print(wrapper())
        print(logo())
        #print(wrapper())
        if player.initiative_roll() &gt;= enemy.initiative_roll():
 
           #player.attack_roll()  METHOD FROM CHARACTER CLASS
           #enemy.defense_roll()  METHOD FROM CHARACTER CLASS
 
           if player.attack_roll() &gt;= enemy.defense_roll():
               #print(wrapper())
               print("Player hits Enemy For: ")
               print(player.damage_roll())
               print(enemy.name)
               #print(enemy.hitpoints - player.damage_roll())
               enemy_damage_taken = enemy.hitpoints - player.damage_roll()
               print(enemy_damage_taken)
               return enemy_damage_taken
               #return  enemy.hitpoints - player.damage_roll()
           else:
               print("Player misses Enemy")
 
        else:
           #enemy.attack_roll()
           #player.defense_roll()
 
           if enemy.attack_roll() &gt;= player.defense_roll():
               #print(wrapper())
               print("Enemy hits Player For:")
               print(enemy.damage_roll())
               print(player.name)
               #print(player.hitpoints - enemy.damage_roll())
               player_damage_taken = player.hitpoints - enemy.damage_roll()
               print(player_damage_taken)
               return player_damage_taken
               #return player.hitpoints - enemy.damage_roll()
 
           else:
               print("Enemy Misses Player")

 

So that’s the basic idea of the MI Python Dungeons and Dragons Random Character and Combat Bot.  We just have to Instantiate the bot below.  Lets make a player bot and an enemy bot.

###  INSTANTIATE CHARACTER CLASSES
###  name,intro,initiative,movement,attack,defense,damage,hitpoints BONUSES
player = character("Player","Player Intro",3,5,3,3,random.randint(1,10),30)
enemy = character("Enemy","Enemy Intro",3,5,3,3,random.randint(1,10),30)

Now lets instantiate the Roll System Class to resolve the rolling of our two character Bots.

###   INSTANTIATE ROLL_SYSTEM CLASS TO HANDLE RANDOM ROLLS
#combat = roll_system((player.attack_roll(),enemy.attack_roll()),())
combat = roll_system()
combat.combat_system()
### RUNS TWICE
combat.combat_system()

That Should be working. Now we have a great start on a basic random combat simulator in Python for Dungeons and Dragons Random Rolls.  Full Code Below.

<pre lang=”python”>

import re
import random
 
def wrapper():
    print("=" * 60)
    print("=" * 60)
def logo():
    print("*" * 60)
    print("MIPYTHON.com | Dungeons and Dragons Random Character and Combat Bot")
    print("*" * 60)
 
 
class character(object):
 
     def __init__(self,name,intro,initiative,movement,attack,defense,damage,hitpoints):
        self.name = name
        self.intro = intro
        self.initiative = initiative
        self.movement = movement
        self.attack = attack
        self.defense = defense
        self.damage = damage
        self.hitpoints = hitpoints
 
 
 
     def main(self):
 
        pass
 
     def initiative_roll(self):
        space = "  "
        self.initiative = self.initiative + random.randint(1,10)
        print(self.name + space + "Initative Roll:")
        print("Rolls: % for Initiative") % self.initiative
        return self.initiative
 
     def move_roll(self):
        space = "  "
        self.movement = (self.movement) + random.randint(1,10)
        print(self.name + space + "Move Roll:")
        print(self.name + "Rolls: " + space + str(self.movement))
        #print(self.movement) #% self.movement
        #return str(self.name) + " Moves :  "
        return self.movement
 
     def attack_roll(self):
 
        space = "  "
        self.attack = self.attack + random.randint(1,99)
        #print("\n Rolls a % To Attack!") % int(self.attack) + random.randint(0,10)
        #return int(self.attack) + random.randint(0,10)
        #print(self.name + "Moves : " + self.movement )
        #print(self.name + "Rolls For Attack:")
        print(self.name + space + "Attack Roll:")
        print(self.name)
        print("Rolls: %" + space + " for Attack") % self.attack
        return self.attack
 
     def defense_roll(self):
        space = "  "
        self.defense = self.defense + random.randint(1,99)
        print(self.name + space + "Defense Roll:")
        print(self.name)
        print("Rolls: % for Defense") % self.defense
        #print(self.defense)
        return self.defense
 
     def damage_roll(self):
        return self.damage
 
class roll_system(object):
 
     def __init__(self):
        pass
        #self.combat_resolving = combat_resolving
        #self.wound_handeling = wound_handeling
 
     def main(self):
        pass
 
     def combat_system(self):
        #print(wrapper())
        print(logo())
        #print(wrapper())
        if player.initiative_roll() &gt;= enemy.initiative_roll():
 
           #player.attack_roll()  METHOD FROM CHARACTER CLASS
           #enemy.defense_roll()  METHOD FROM CHARACTER CLASS
 
           if player.attack_roll() &gt;= enemy.defense_roll():
               #print(wrapper())
               print("Player hits Enemy For: ")
               print(player.damage_roll())
               print(enemy.name)
               #print(enemy.hitpoints - player.damage_roll())
               enemy_damage_taken = enemy.hitpoints - player.damage_roll()
               print(enemy_damage_taken)
               return enemy_damage_taken
               #return  enemy.hitpoints - player.damage_roll()
           else:
               print("Player misses Enemy")
 
        else:
           #enemy.attack_roll()
           #player.defense_roll()
 
           if enemy.attack_roll() &gt;= player.defense_roll():
               #print(wrapper())
               print("Enemy hits Player For:")
               print(enemy.damage_roll())
               print(player.name)
               #print(player.hitpoints - enemy.damage_roll())
               player_damage_taken = player.hitpoints - enemy.damage_roll()
               print(player_damage_taken)
               return player_damage_taken
               #return player.hitpoints - enemy.damage_roll()
 
           else:
               print("Enemy Misses Player")
 
###  INSTANTIATE CHARACTER CLASSES
###  name,intro,initiative,movement,attack,defense,damage,hitpoints BONUSES
player = character("Player","Player Intro",3,5,3,3,random.randint(1,10),30)
enemy = character("Enemy","Enemy Intro",3,5,3,3,random.randint(1,10),30)
 
 
###   INSTANTIATE ROLL_SYSTEM CLASS TO HANDLE RANDOM ROLLS
#combat = roll_system((player.attack_roll(),enemy.attack_roll()),())
combat = roll_system()
combat.combat_system()
### RUNS TWICE
combat.combat_system()
 
 
"""run = True
while run == True:
    #combat.combat_system()
    combat = input("Combat Y or N ?&gt;&gt;&gt;")
    combat.combat_system()
    if combat == "N":
        run = False
    else:
        combat.combat_system()"""
 
 
"""while player.hitpoints &gt;= 0 :
    combat.combat_system()
    go_again = input("Continue Y or N?&gt;&gt;&gt; ")
 
    if go_again == "Y" or go_again == "y":
        combat.combat_system()
    else:
        print("YOU ARE DEAD")
else:
    print("You are Dead")"""
 
#print(player.intro)
#print(enemy.intro)
#player.initiative_roll()
#player.move_roll()
#player.attack_roll()
#player.defense_roll()
 
#player.initiative_roll()
#enemy.initiative_roll()
#player.initiative_roll()
#enemy.initiative_roll()
 
 
 
#print(player.move())
#print(player.movement)
 
#if __name__ == '__main__':
    # main()
 
 &lt;/pre&gt; 
 
More Python Selenium WEB 3.0 Bot  <a href="http://mipython.magwebdesigns.net/WP/2018/04/06/python-selenium-best-practice-for-web-automation-bot-s-2018/">Tutorials</a>.

Related posts