Ejemplo n.º 1
0
    def __init__(self):
        self.inventory = Inventory()

        self.image = SpriteSheet("media/char.png").get_sprite(0, 0, 32, 48)
        self.rect = self.image.get_rect()

        # Used to delay moving player till the collision will be checked
        # TODO: Change vector to class
        self.vector = {"x": 0, "y": 0}

        self.x = 200
        self.y = 200

        # FIXME: Connected with fixme from platform.py
        # If you consider it's stupid know that when you player he is on different position
        # till he will be updated and collide with newly created items
        self.rect.x = self.y
        self.rect.y = self.x

        # Actual sprite position
        self.sprite_col = 0
        self.sprite_row = 0

        # Used to draw sprite at certain frames
        self.frame = 0

        # Save attacking state:
        self.attacking = False
        self.attacking_time = 0
Ejemplo n.º 2
0
    def init_player(race, prof, name):
        consts = Constants.consts
        race_dict = consts[race]
        prof_dict = consts[prof]
        hp = race_dict['hp'] + prof_dict['hp_bonus']
        defense = race_dict['defense'] + prof_dict['def_bonus']
        power = race_dict['power'] + prof_dict['power_bonus']
        xp = 0
        armor = 0
        mana = race_dict['mana'] + prof_dict['mana_bonus']
        magic = race_dict['magic'] + prof_dict['magic_bonus']
        fighting = race_dict['fighting'] + prof_dict['fighting_bonus']
        shielding = race_dict['shielding'] + prof_dict['shielding_bonus']
        conjuring = race_dict['conjuring'] + prof_dict['conjuring_bonus']
        archery = race_dict['archery'] + prof_dict['archery_bonus']
        transmutations = race_dict['transmutations'] + prof_dict['transmutations_bonus']
        hexes = race_dict['hexes'] + prof_dict['hexes_bonus']
        speed = race_dict['speed']
        mana_regen = race_dict['mana_regen']

        fighter_component = Fighter(hp, defense, power, xp, armor, mana, magic,
                                    death_function=DeathFunctions.player_death,
                                    fighting=fighting, shielding=shielding, conjuring=conjuring,
                                    archery=archery, transmutations=transmutations, hexes=hexes,
                                    speed=speed, mana_regen=mana_regen)
        fighter_component.stealthiness = race_dict['stealthiness']

        inv_component = Inventory()

        player = Entity(0, 0, consts['player_tile'], name, libtcod.white, blocks=True, fighter=fighter_component,
                        race=race, prof=prof, inventory=inv_component)
        player.level = 1
        player.isplayer = True
        return player
Ejemplo n.º 3
0
 def __init__(self,
              score: float = 0,
              origin: int = 0,
              level: int = 0,
              inventory: Inventory = Inventory()):
     self.score = score
     self.origin = origin
     self.level = level
     self.inventory = inventory
Ejemplo n.º 4
0
 def look(self):
     self.write('Look')
     data = parse_response_array(self.responses.get())
     self.player.vision = []
     for s in data:
         vision = Inventory([0] * len(_ITEMS))
         segment = s.strip().split(' ')
         for key in segment:
             if find(vision.keys(), key=lambda x: x == key) is not None:
                 vision[key] += 1
         self.player.vision.append(vision)
Ejemplo n.º 5
0
class Player:
	level = 1
	position: Vec2d = Vec2d(0, 0)
	orientation = 0
	inventory = Inventory()
	vision = []

	def __init__(self, pid: int, pos: Vec2d or None):
		self.id = pid
		self.position = pos if not None else Vec2d(0, 0)
		for x in range(4):
			self.vision.append(Inventory())

	def to_str(self) -> str:
		return f'{self.level};{self.inventory}'
Ejemplo n.º 6
0
    def __init__(self, hwnd, coordinates):

        print("DEBUG: setting up runescape client instance")

        self.hwnd = hwnd
        self.coordinates = coordinates

        self.exchange = exchange.Exchange(self.coordinates)
        self.is_member = config.membership

        if os.path.exists("./data/dynamic_coordinates.json"):

            file = open('./data/dynamic_coordinates.json', 'r')
            coords = json.load(file)

            self.inventory = Inventory(
                utils.dynamic_coordinate_converter(self.coordinates,
                                                   coords['inventory_window'],
                                                   '+'))
        self.inventory.inventory_list[0].set(items.Item('coins'),
                                             self.find_coins())
        print("DEBUG: Coins in inventory",
              self.inventory.inventory_list[0].amount)
Ejemplo n.º 7
0
import random

from classes.game import Character
from classes.magic import Spell
from classes.inventory import Inventory

# Spells
iceBolt = Spell("Ice bolt", 12, 40, "Ice")
fireBolt = Spell("Fire bolt", 5, 15, "Fire")
earthBolt = Spell("Earth bolt", 26, 57, "Earth")
windBolt = Spell("Wind bolt", 1, 10, "Wind")
heal = Spell("Lesser Heal", 2, 10, "White")

# Items
smallPotion = Inventory("Small Potion", "potion", "Heals you for 25hp", 25)
potion = Inventory("Potion", "potion", "Heals you for 100hp", 100)
bomb = Inventory("Bomb", "attack", "Attacks enemy for 350hp", 200)

# Characters
hero = Character(500, 120, 50, 30, [iceBolt, fireBolt, earthBolt, windBolt, heal], [smallPotion, potion, bomb])
enemy = Character(450, 100, 20, 30, [windBolt, earthBolt], [smallPotion, bomb, potion])

running = True

while running:

    # ___PLAYER ACTION____
    print("+==================+")
    hero.chooseAction()
    select = input("Choose action:")
    index = int(select) - 1
Ejemplo n.º 8
0
	def __init__(self, pid: int, pos: Vec2d or None):
		self.id = pid
		self.position = pos if not None else Vec2d(0, 0)
		for x in range(4):
			self.vision.append(Inventory())
Ejemplo n.º 9
0
from classes.inventory import Inventory
from constants import game_settings as gs
from constants import voice_settings as vs
from constants import speech_settings as ss
from constants import entity_settings as es
from functions import load
import pygame as pg
from classes import player, objects
from classes import mapping
from functions import speech

inventory = Inventory(player, 10, 5, 2)

playerList = ("Adam", "Alex", "Amelia", "Bob", "Bouncer", "Conference_man",
              "Conference_woman", "Dan", "Edward", "Halloween_Kid_1",
              "kid_Abby", "kid_Oscar", "Lucy", "Molly", "Old_man_Josh",
              "Old_woman_Jenny", "Pier", "Rob", "Roki", "Samuel",
              "Santa_claus")
clickArrow = False
compteur = 0


def win_init():
    pg.display.set_caption("HETIC LIFE")  #window title
    # Game Icon (HETIC LOGO)
    pg.display.set_icon(pg.image.load("img/game_icon.png"))
    gs.win = pg.display.set_mode((gs.WIDTH, gs.HEIGHT))
    pg.mouse.set_cursor(*pg.cursors.diamond)
    gs.run = True
    gs.clock = pg.time.Clock()
    init_game()
Ejemplo n.º 10
0
import json
from random import randint

from numpy.core.umath import sign

from classes.client import Client, clamp
from classes.inventory import Inventory
from common.listtools import find, index
from common.vec import Vec2d

_RESOURCES_NEEDED = [
    Inventory([0, 1, 0, 0, 0, 0, 0, 1]),
    Inventory([0, 1, 1, 1, 0, 0, 0, 2]),
    Inventory([0, 2, 0, 1, 0, 2, 0, 2]),
    Inventory([0, 1, 1, 2, 0, 1, 0, 4]),
    Inventory([0, 1, 2, 1, 3, 0, 0, 4]),
    Inventory([0, 1, 2, 3, 0, 1, 0, 6]),
    Inventory([0, 2, 2, 2, 2, 2, 1, 6])
]


class PlayerDesc:
    score: float
    origin: int
    level: int
    inventory: Inventory

    def __init__(self,
                 score: float = 0,
                 origin: int = 0,
                 level: int = 0,