示例#1
0
文件: object.py 项目: jnewblanc/sog
    def cast(self, charObj, targetObj):
        """ cast a spell using a device """
        if self.getCharges() <= 0:
            charObj.client.spoolOut("This item has no charges left\n")
            return False
        if self.getCharges() == 1:
            if self.getType() == "Scroll":
                charObj.client.spoolOut(
                    self.describe(article="The") + " disintegrates\n"
                )
            else:
                charObj.client.spoolOut(self.describe(article="The") + " fizzles\n")

        spellName = self.getSpellName()
        # With devices, spellChant is not required, so we get it and pass it in
        spellChant = getSpellChant(spellName)

        # create the spell object, which determines if it succeeds
        spellObj = Spell(
            charObj,
            targetObj,
            spellName,
            chant=spellChant,
            requiresmana=False,
            useSelfCriteria=False,
        )

        # Apply effects of spell
        if spellObj.cast(charObj.getRoom()):
            pass
        else:
            charObj.client.spoolOut(spellObj.getFailedReason() + "\n")

        self.decrementChargeCounter()

        return None
示例#2
0
import random
from game import Person, bcolors
from magic import Spell
from inventory import Item

newfile = open("stats.txt", "w+")
# Offensive spells
Fire = Spell("Fire", 30, 30, "Offensive")
Thunder = Spell("Thunder", 150, 120, "Offensive")
Blizzard = Spell("Blizzard", 50, 70, "Offensive")
Meteor = Spell("Meteor", 200, 300, "Offensive")
Quake = Spell("Quake", 100, 100, "Offensive")

# Defensive spells
Heal = Spell("Heal", 12, 100, "Defensive")
Super_Heal = Spell("Super_Heal", 20, 200, "Defensive")

# Create items
Potion = Item("Potion", "HP_potion", "Heals 50 HP", 50)
SuperPotion = Item("SuperPotion", "HP_potion", "Heals 150 HP", 150)
Elixer = Item("Elixer", "elixer", "Fully restores HP/MP", 9999)
ManaPotion = Item("ManaPotion", "MP_potion", "Restore 50 MP", 50)
Sword = Item("Sword", "Weapon", "Deals bonus 50 dmg", 50)
Axe = Item("Axe", "Weapon", "Deals bonus 75 HP", 75)
Bow = Item("Bow", "Weapon", "Deals bonus 50 dmg", 50)
Hammer = Item("Hammer", "Weapon", "Deals bonus 100 dmg", 100)
Dagger = Item("Dagger", "Weapon", "Deals bonus 25 dmg", 20)

# Spells
mage_spells = [Fire, Quake, Blizzard, Meteor, Heal, Super_Heal]
warrior_spells = [Fire, Heal]
示例#3
0
from game import Person, bcolors
from magic import Spell
from inventory import Item
import random
 
print("\n\n")
# Create Black Magic
fire = Spell("Fire", 25, 600, "black")
thunder = Spell("Thunder", 25, 600, "black")
blizzard = Spell("Blizzard", 25, 600, "black")
meteor = Spell("Meteor", 40, 1200, "black")
quake = Spell("Quake", 14, 140, "black")
 
# Create White Magic
cure = Spell("Cure", 25, 620, "white")
cura = Spell("Cura", 32, 1500, "white")
curaga = Spell("Curaga", 50, 6000, "white")
 
 
# Create some Items
potion = Item("Potion", "potion", "Heals 50 HP", 50)
hipotion = Item("Hi-Potion", "potion", "Heals 100 HP", 100)
superpotion = Item("Super Potion", "potion", "Heals 1000 HP", 1000)
elixer = Item("Elixer", "elixer", "Fully restores HP/MP of one party membrer", 9999)
hielixer = Item("MegaElixer", "elixer", "Fully restores party's HP/MP", 9999)
 
grenade = Item("Grenade", "attack", "Deals 500 damage", 500)
 
player_spells = [fire, thunder, blizzard, meteor, cure, cura]
enemy_spells = [fire, meteor, curaga]
player_items = [{"item": potion, "quantity": 15}, {"item": hipotion, "quantity": 5},
示例#4
0
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Tue Jul 31 20:33:23 2018

@author: fasih
"""
from magic import Spell
from RPG_Battle import Person, bcolors
from inventory import Item

# Create black Magic
fire = Spell("Fire", 10, 100, "black")
thunder = Spell("Thunder", 10, 100, "black")
meteor = Spell("Metor", 20, 200, "black")
blazzerd = Spell("Blazzerd", 10, 100, "black")
quake = Spell("Quake", 14, 140, "black")
#some White Magic
cure = Spell("Cure", 12, 120, "White")
cura = Spell("Cura", 18, 200, 'White')

#creating Inventory
potion = Item("Potion", 'potion', 'heals 50 HP', 50)
hipotion = Item("Hi Potion", 'potion', 'heals 100 HP', 100)
superpotion = Item("Mega Potion", 'potion', 'heals 500 HP', 500)
elixer = Item("Elixer", 'elixer', 'Fully restore one person HP', 99999)
HiElixer = Item("Mega elixer", 'elixer', 'Fully restore all charactors Hp/Mp',
                99999)
granade = Item("Grenade", 'attack', 'deals 500 damage point', 500)

player_magic = [fire, thunder, blazzerd, meteor, cure, cura]
 def __init__(self):
     Spell.__init__(self)
     self.color = WHITE
     self.type = ST_ORDER
示例#6
0
 def test_init_spell(self):
     spell = Spell("Fire", 10, 100, "black")
     self.assertTrue(spell.name,"Fire")
     self.assertTrue(spell.cost, 10)
     self.assertTrue(spell.dmg, 100)
     self.assertTrue(spell.type, "black")
示例#7
0
 def test_generate_spell_damage(self):
     rand_int = random.randint(1, 100)
     blizzard = Spell("blizzard", 10, rand_int, "black")
     dmg = blizzard.generate_damage()
     self.assertLess(rand_int - 16, dmg)
     self.assertGreater(rand_int + 16, dmg)
 def __init__(self):
     Spell.__init__(self)
     self.color = BLUE
     self.type = ST_GENERIC
示例#9
0
print("\n")
print(bcolors.FAIL + bcolors.BOLD + "An Enemy Attacks!!" + bcolors.ENDC)
print(
    bcolors.OKBLUE, bcolors.BOLD,
    "NAME                                   HP                            MP",
    bcolors.ENDC)
# print("\n\n")
"""magic = [{"name": "Fire", "cost": 10, "dmg": 100},
         {"name": "Thunder", "cost": 10, "dmg": 120},
         {"name": "Blizzard", "cost": 10, "dmg": 80}]
"""

# Instantiate Black magic
# (self, name, cost, dmg, type_spell):
fire = Spell("Fire", 30, 332, "black")
thunder = Spell("Thunder", 40, 488, "black")
blizzard = Spell("Blizzard", 10, 145, "black")
meteor = Spell("Meteor", 50, 650, "black")
quake = Spell("Quake", 20, 256, "black")

# Instantiate White Magic
cure = Spell("Cure", 80, 1000, "white")
cura = Spell("Cura", 100, 1500, "white")

# Instantiate Inventory
# (self, name, types, description, prop)
potion = Item("Potion", "potion", "Heals 50 HP", 50)
hipotion = Item("Hi-Potion", "potion", "Heals 100 HP", 100)
superpotion = Item("Super-Potion", "potion", "Heals 150 HP", 150)
elixer = Item("Elixer", "elixer", "Fully restores HP/MP", 99999)
 def __init__(self):
     Spell.__init__(self)
     self.color = WHITE
     self.type = ST_ORDER
 def __init__(self):
     Spell.__init__(self)
     self.color = GREEN
     self.type = ST_GENERIC
示例#12
0
from game import Person, bcolors
from magic import Spell
from inventory import Item
import random


# create Black Magic:
fire = Spell("Fire", 30, 150, "Black")
thunder = Spell("Thunder", 40, 200, "Black")
blizzard = Spell("Blizzard", 35, 170, "Black")
meteor = Spell("Meteor", 20, 110, "Black")
quake = Spell("Quake", 25, 130, "Black")

# create White Magic:
cure = Spell("Cure", 40, 1000, "White")
cura = Spell("Cura", 60, 1500, "White")

# Create some Items to be used
potion = Item("Potion", "Potion", "Heals 50 Hp", 50, 10)
hipotion = Item("Hipotion", "Potion", "Heals 100 Hp", 100, 5)
superpotion = Item("Superpotion", "Potion", "Heals 500 Hp", 500, 5)
elixir = Item("Elixir", "Elixir", "Fully restores HP/MP of one party member", 9999, 5)
superelixir = Item("Superelixir", "Elixir", "Fully restores Party's HP/MP", 9999, 2)
grenade = Item("Grenade", "Attack", "Deals 500 damage", 500, 3)

# Adding magic spells for the player
player_magic = [fire, thunder, blizzard, meteor, quake, cure, cura]

# Adding magic spells for the enemy
enemy_magic = [fire, thunder, blizzard, cure]
 def __init__(self):
     Spell.__init__(self)
     self.color = RED
     self.type = ST_GENERIC
示例#14
0
from person import Person
from magic import Spell
from inventory import Item
from player import Player
from description import description
from battle import battle
from battle2 import PvP
from cube import cube
from bcolors import bcolors

# Umiejętności
power_hit = Spell("Potężne Uderzenie", 30, 180, "black")
smash = Spell("Miazga", 40, 220, "black")
ignite = Spell("Podpalenie", 30, 110, "black")
meteor = Spell("Meteor", 40, 200, "black")
smite = Spell("Porażenie", 35, 190, "black")
thunder = Spell("Błyskawica", 45, 280, "black")
element_ball = Spell("Kula Żywiołów", 50, 340, "black")
tempest = Spell("Nawałnica Stali", 70, 500, "black")
penetration = Spell("Penetracja", 85, 650, "black")
assassination = Spell("Natychmiastowe zabójstwo", 250,
                      9999999999999999999999999999, "black")
shout = Spell("'Tanio skóry nie sprzedam'", 220, 0, "black")
carnage = Spell("Rzeź", 50, 250, "black")
stone_fists = Spell("Kamienne Pięści", 40, 200, "black")
cure = Spell("Uleczenie", 55, 300, "white")
heal = Spell("Uzdrowienie", 200, 9999999999999999999999999999999, "white")
block = Spell("Garda", 20, 0, "block")
HP_steal = Spell("Kradzież życia", 50, 250, "HP steal")
MP_steal = Spell("Kradzież many", 25, 50, "MP steal")
stun = Spell("Ogłuszenie", 120, 0, "stun")
示例#15
0
from game import Player, bcolors
from magic import Spell
from inventory import Item
import random

print(bcolors.FAIL + bcolors.BOLD + "AN ENEMY APPEARS!" + bcolors.ENDC)

###Spells###
#Dark Spells
meteor = Spell("Meteor Strike", 20, 50, "Dark")
typhoon = Spell("Typhoon Strike", 25, 55, "Dark")
lighting = Spell("Lightning Strike", 50, 70, "Dark")
ultra = Spell("PLUS ULTRA", 100, 100, "Dark")
#Light Spells
cure = Spell("Cure", 10, 15, "Light")
cure_p = Spell("Cure +", 15, 20, "Light")

player1_spells = [meteor, typhoon, lighting, ultra, cure, cure_p]
enemy_spells = [meteor, lighting, cure]

###Items###
#Health Potions
red_potion = Item("Red Potion", "Potion", "Heals 10 HP", 10)
orange_potion = Item("Orange Potion", "Potion", "Heals 25 HP", 25)
white_potion = Item("White Potion", "Potion", "Heals 50 HP", 50)
#Mana Potions
blue_potion = Item("Blue Potion", "Potion", "Heals 10 MP", 10)
big_blue_potion = Item("Big Blue Potion", "Potion", "Heals 50 MP", 50)
#Elixirs
purple_elixir = Item("Purple Elixir", "Elixir",
                     "Fully restores HP/MP of one party member", 999)
示例#16
0
#from inventory import Item
from battle import Person, bcolors
from magic import Spell

#create Black magic
fire = Spell("Fire ", 10, 100, "black")
thunder = Spell("Thunder ", 10, 100, "black")
blizzard = Spell("Blizzard ", 10, 100, "black")
meteor = Spell("Meteor ", 10, 100, "black")
quake = Spell("Quake ", 10, 100, "black")

#create white magic_choice
cure = Spell("Cure ", 12, 120, "white")
cura = Spell("Cura ", 18, 200, "white")

#create some items
#potion=Item

#instantiate People
player = Person(460, 65, 60, 34,
                [fire, thunder, blizzard, meteor, quake, cure, cura])
enemy = Person(1200, 65, 45, 25, [])
running = True
i = 0

print(bcolors.BOLD + "AN ENEMY ATTACKS" + bcolors.ENDC)

while running:
    print("========================================")
    player.choose_action()
    choice = input(bcolors.UNDERLINE + " Choose Action: " + bcolors.ENDC)