Return to repo list

heart-of-gold

Tactical RPG written in python, using pygame.
Return to HMagellan.com

constants.py (4842B)


      1 import os, enum, json, pathlib
      2 
      3 ################
      4 # constants.py #
      5 ################
      6 
      7 # This file contains:
      8 #   1. Important environment values that exist independent of any one source file
      9 
     10 # TODO: This file should source from a settings file
     11 
     12 #########################
     13 # Section 1 - Constants #
     14 #########################
     15 
     16 # Game settings
     17 SCREEN_WIDTH = 1024
     18 SCREEN_HEIGHT = 768
     19 FRAMERATE = 60
     20 
     21 # Tile constants
     22 TILE_WIDTH = 64
     23 TILE_HEIGHT = 64
     24 COLORKEY = (255, 0, 255)
     25 
     26 # Other constants
     27 PIECE_MOVE_SPEED = 4
     28 PIECE_MOVE_DELAY = PIECE_MOVE_SPEED * 4
     29 SCROLL_SPEED = 4
     30 UI_FONT = "ArchivoNarrow-Regular.otf"
     31 
     32 # File paths
     33 DATA_PATH = os.path.join(os.getcwd(), "data")
     34 IMAGE_PATH = os.path.join(DATA_PATH, "img")
     35 SOUND_PATH = os.path.join(DATA_PATH, "snd")
     36 FONT_PATH = os.path.join(DATA_PATH, "font")
     37 BOARD_PATH = os.path.join(DATA_PATH, "board")
     38 TILE_PATH = os.path.join(DATA_PATH, "tsx")
     39 JSON_PATH = os.path.join(DATA_PATH, "json")
     40 MENU_JSON_PATH = os.path.join(JSON_PATH, "menus")
     41 SCENE_JSON_PATH = os.path.join(JSON_PATH, "scenes")
     42 ACTORS_PATH = os.path.join(IMAGE_PATH, "actors")
     43 SAVE_PATH = os.path.join(str(pathlib.Path.home), ".local", "share", "heart-of-gold", "savegames")
     44 
     45 # Piece constants
     46 with open(os.path.join(JSON_PATH, "pieces.json")) as f: CHARBASE = json.load(f)
     47 AFFINITIES = ("Fire", "Wind", "Life", "Miasma", "Water", "Lightning")
     48 AFFINITY_RELATIONS = {
     49     "Fire" : { "Opposite" : "Wind", "Weak" : "Water", "Strong" : "Life" },
     50     "Wind" : { "Opposite" : "Fire", "Weak" : "Lightning", "Strong" : "Miasma" },
     51     "Life" : { "Opposite" : "Miasma", "Weak" : "Fire", "Strong" : "Water" },
     52     "Miasma" : { "Opposite" : "Life", "Weak" : "Wind", "Strong" : "Lightning" },
     53     "Water" : { "Opposite" : "Lightning", "Weak" : "Life", "Strong" : "Fire" },
     54     "Lightning" : { "Opposite" : "Water", "Weak" : "Miasma", "Strong" : "Wind" }
     55 }
     56 
     57 # Item constants
     58 with open(os.path.join(JSON_PATH, "items.json")) as f: ITEMBASE = json.load(f)
     59 WEAPON_TYPE_SOURCES = {
     60     "Dagger" : "ATK",
     61     "Sword" : "ATK",
     62     "Spear" : "ATK",
     63     "Axe" : "ATK",
     64     "Glove" : "ATK",
     65     "Blunt" : "ATK",
     66     "Bow" : "ACC",
     67     "Thrown" : "ACC",
     68     "Staff" : "INT",
     69     "Book" : "INT",
     70     "Wand" : "INT"
     71 }
     72 WEAPON_TYPE_BONUSES = {
     73     "Dagger" : "SPD",
     74     "Sword" : None,
     75     "Spear" : "DEF",
     76     "Axe" : "ATK",
     77     "Glove" : "SPD",
     78     "Blunt" : None,
     79     "Bow" : "ACC",
     80     "Thrown" : "ATK",
     81     "Staff" : "ATK",
     82     "Book" : "WIS",
     83     "Wand" : "INT"
     84 }
     85 
     86 # Stat constants
     87 BASIC_STATS = ["ATK", "DEF", "INT", "WIS", "SPD", "ACC", "LUK"]
     88 RESERVE_STATS = ["MOVE", "INIT", "CNTR", "GARD", "PUSH", "SKLL", "PASS"]
     89 OTHER_STATS = ["HP", "EXP", "LVL", "RNK"]
     90 
     91 # Enums
     92 STATE_MODES = enum.Enum('STATE_MODES', 'Main_Menu_Mode Base_Mode Battle_Mode Still_Scene_Mode')
     93 CTRL_MODES = enum.Enum('CTRL_MODES', 'No_Control Main_Menu_Normal Base_Normal Base_Dialog Base_Pause Base_Pause_Save Base_Pause_Load Turn_Normal Turn_Pause Turn_Select_Move Turn_Select_Attack Turn_Choose_Skill Turn_Choose_Item Turn_Select_Push Turn_Watch_Move Turn_Watch_Attack Turn_Display_Stats Turn_Watch_Guard Battle_Dialog Battle_Intro Battle_Resolve Battle_Summary Still_Scene_Normal')
     94 FACE_DIR = enum.Enum('FACE_DIR', 'U D L R')
     95 GAME_EFFECTS = enum.Enum('GAME_EFFECTS', 'ef_game_dummy ef_game_quit ef_game_switch_mode ef_game_switch_control')
     96 MENU_EFFECTS = enum.Enum('MENU_EFFECTS', 'ef_menu_dummy')
     97 SCENE_EFFECTS = enum.Enum('SCENE_EFFECTS', 'ef_scene_dummy ef_scene_delay ef_scene_fade ef_scene_scroll_camera ef_scene_snap_camera ef_scene_spawn_piece')
     98 TEAMS = enum.Enum('TEAMS', 'Player Ally Neutral Enemy Other')
     99 ATTACK_NOTATIONS = enum.Enum('ATTACK_NOTATIONS', 'backattack critical counter opposite weakness resist riposte ignoredef parry block sweep miss onetwo stun')
    100 
    101 # Mode/Enum element collections
    102 EXITABLE_TURN_MODES = [
    103     CTRL_MODES.Turn_Select_Move, 
    104     CTRL_MODES.Turn_Select_Attack,
    105     CTRL_MODES.Turn_Select_Push,
    106     CTRL_MODES.Turn_Choose_Skill,
    107     CTRL_MODES.Turn_Choose_Item
    108 ]
    109 SCROLLABLE_TURN_MODES = [
    110     CTRL_MODES.Turn_Normal,
    111     CTRL_MODES.Turn_Select_Move, 
    112     CTRL_MODES.Turn_Select_Attack,
    113     CTRL_MODES.Turn_Select_Push
    114 ]
    115 PAUSE_MODES = [
    116     CTRL_MODES.Base_Pause,
    117     CTRL_MODES.Base_Pause_Save,
    118     CTRL_MODES.Base_Pause_Load,
    119     CTRL_MODES.Turn_Pause,
    120     CTRL_MODES.Turn_Display_Stats
    121 ]
    122 PLUMB_BOB_DRAW_TURN_MODES = [
    123     CTRL_MODES.Turn_Normal, 
    124     CTRL_MODES.Turn_Select_Move, 
    125     CTRL_MODES.Turn_Select_Attack,
    126     CTRL_MODES.Turn_Choose_Skill,
    127     CTRL_MODES.Turn_Choose_Item,
    128     CTRL_MODES.Turn_Select_Push
    129 ]
    130 
    131 # Save environment
    132 SAVE_ENV = {
    133     "profile_name" : "",
    134     "save_slot" : -1,
    135     "pieces" : [],
    136     "items" : [],
    137     "hq_upgrades" : [],
    138     "progress_state" : -1,
    139     "unlock_flags" : []
    140 }
    141 
    142 # Error types
    143 class ManagerBusError(Exception):
    144     """
    145     Raised when an error occurs as part of ManagerBus
    146     operation.
    147     """