Skip to content

Instantly share code, notes, and snippets.

@Ryex

Ryex/Event.py Secret

Last active August 29, 2015 14:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Ryex/1f12aecc6a5e6b115c24 to your computer and use it in GitHub Desktop.
Save Ryex/1f12aecc6a5e6b115c24 to your computer and use it in GitHub Desktop.
EventCommand prams map
#this class in in RGSS1_RPG.py, it is seperated out here for refrence
class _EventCommand(object):
_arc_class_path = "RPG::EventCommand"
_arc_instance_variables = ['code', 'indent', 'parameters']
def __init__(self, code=0, indent=0, parameters=[]):
self.code = code #int eventcode
self.indent = indent #int indent level
self.parameters = parameters #array of peramiters
from Boot import WelderImport
Kernel = WelderImport('Kernel')
Manager = Kernel.Manager
Type = Kernel.Type
SuperType = Kernel.SuperType
Component = Kernel.Component
Package = Kernel.Package
KM = Kernel.Manager
class EventCommandFormater(object):
'''Formats event commands into HTML for display'''
@staticmethod
def format(command):
html = ""
formater = EventCommandFormater.get_event_formater(command.code).object
if formater is None:
return ''.join(("&nbsp;" * 4 * command.indent, '<font color="red"><b>ERROR:</b> No Handeler for event code [%s]</font>' % command.code))
format = formater.format(command.parameters)
template = formater.template(format)
if template == "":
return ''.join(("&nbsp;" * 4 * command.indent, '<font color="red"><b>ERROR:</b> Event code [%s] defined but not implemented</font>' % command.code))
return ''.join(("&nbsp;" * 4 * command.indent, template))
@staticmethod
def get_event_formater(code):
name = "Command%03d" % code
return KM.get_type("EventFormaterType").get_type(name).get_default_component()
class Format(object):
@staticmethod
def red(text):
return '<font color="red">%s</font>' % text
@staticmethod
def blue(text):
return '<font color="blue">%s</font>' % text
@staticmethod
def green(text):
return '<font color="green">%s</font>' % text
@staticmethod
def bold(text):
return '<b>%s</b>' % text
@staticmethod
def italic(text):
return '<i>%s</i>' % text
@staticmethod
def color(color, text):
return '<font color="%s">%s</font>' % (color, text)
@staticmethod
def colorObj(color):
template = Format.color('black', '<b>Color</b>(%s, %s, %s, %s)')
colors = (
Format.red('%3d'),
Format.green('%3d'),
Format.blue('%3d'),
Format.bold('%3d')
)
data = (
color.red,
color.green,
color.blue,
color.alpha
)
return (template % colors) % data
@staticmethod
def audioFile(audiofile):
template = Format.color('black', '<b>Audio</b>{:name => %s, :volume => %s, :pitch => %s}')
colors = (
Format.green('%s'),
Format.red('%3d'),
Format.red('%3d')
)
data = (
audiofile.name,
audiofile.volume,
audiofile.pitch
)
return (template % colors) % data
@staticmethod
def item(item):
template = Format.color('black', 'Item [%s: %s]')
colors = (Format.red('%03d'), Format.green('%s'))
data = (item.id, item.name)
return (template % colors) % data
@staticmethod
def weapon(weapon):
template = Format.color('black', 'Weapon [%s: %s]')
colors = (Format.red('%03d'), Format.green('%s'))
data = (weapon.id, weapon.name)
return (template % colors) % data
@staticmethod
def armor(armor):
template = Format.color('black', 'Armor [%s: %s]')
colors = (Format.red('%03d'), Format.green('%s'))
data = (armor.id, armor.name)
return (template % colors) % data
class Command000(object):
"""place holder"""
@staticmethod
def format(params):
format = {}
format['params'] = params
return format
@staticmethod
def template(format):
return Format.color('#0000A0', Format.bold('@>'))
class Command101(object):
"""Show Text"""
@staticmethod
def format(params):
format = {}
format['text'] = params[0]
return format
@staticmethod
def template(format):
template = '%s %s' % (Format.green('Text:'), Format.italic('%(text)s'))
return template % format
class Command401(object):
"""Show Text Extra Lines"""
@staticmethod
def format(params):
format = {}
format['text'] = params[0]
return format
@staticmethod
def template(format):
template = '&nbsp;&nbsp;&nbsp;&nbsp;%s %s' % (Format.green(':'), Format.italic('%(text)s'))
return template % format
class Command102(object):
"""Show Choices"""
@staticmethod
def format(params):
format = {}
format['choice_number'] = len(params[0])
format['choice_choices'] = params[0]
format['choice_default'] = params[1]
return format
@staticmethod
def template(format):
choices = ''
for i in xrange(format['choice_number']):
choices += '(%s)%s' % (Format.red(i), Format.green(format['choice_choices'][i]))
if i < format['choice_number'] - 1:
choices += ', '
format['choice_text'] = choices
template = ('%s ' * 5) % (
Format.color('#25383C', 'Show Choices:'),
Format.blue(Format.bold(' Case')),
Format.italic('[%(choice_text)s]'),
Format.blue(Format.bold('Default')),
Format.red('%(choice_default)d')
)
return template % format
class Command402(object):
"""When [**] The command that serves as an entry point for each potential choice"""
@staticmethod
def format(params):
format = {}
format['choice_name'] = params[1]
format['choice_id'] = params[0]
return format
@staticmethod
def template(format):
template = '&nbsp;&nbsp;%s (%s)%s' % (Format.blue(Format.bold('When')), Format.red('%(choice_id)s'), Format.green('%(choice_name)s'))
return template % format
class Command403(object):
"""When Cancel Choices"""
@staticmethod
def format(params):
format = {}
return format
@staticmethod
def template(format):
return '&nbsp;&nbsp;%s %s' % (Format.blue(Format.bold('When')), Format.green('Cancel'))
class Command103(object):
"""Input Number"""
@staticmethod
def format(params):
project = Kernel.GlobalObjects.get_value("PROJECT")
system = project.getData('System')
format = {}
format['variable_id'] = params[0]
format['variable_name'] = system.variables[params[0]]
format['digits'] = params[1]
return format
@staticmethod
def template(format):
template = '%s Variable[%s: %s], (%s digit(s))' % (Format.blue('Input Number:'),
Format.red('%(variable_id)04d'),
Format.green('%(variable_name)s'),
Format.bold('%(digits)s'))
return template % format
class Command104(object):
"""Change Text Options"""
@staticmethod
def format(params):
format = {}
pos_dict = {
0: 'Top', 1: 'Middle', 2: 'Bottom'
}
visible_dict = {
0: 'Show', 1: 'Hide'
}
format['msg_pos'] = pos_dict[params[0]]
format['msg_frame'] = visible_dict[params[1]]
return format
@staticmethod
def template(format):
template = '%s [%s, %s]' % (Format.italic('Change Text Options:'), Format.bold('%(msg_pos)s'), Format.bold('%(msg_frame)s'))
return template % format
class Command105(object):
"""Button Input Processing"""
@staticmethod
def format(params):
project = Kernel.GlobalObjects.get_value("PROJECT")
system = project.getData('System')
format = {}
format['var_id'] = params[0]
format['var_name'] = system.variables[params[0]]
return format
@staticmethod
def template(format):
template = '%s Variable[%s: %s]' % (Format.bold(Format.red('Button Input Processing: ')), Format.red('%(var_id)04d'), Format.green('%(var_name)s'))
return template % format
class Command106(object):
"""Wait"""
@staticmethod
def format(params):
format = {}
format['frames'] = params[0]
return format
@staticmethod
def template(format):
template = '%s %s %s' % (Format.blue(Format.bold('Wait:')), Format.red('%(frames)s'), Format.red('Frame(s)'))
return template % format
class Command108(object):
"""Comment"""
@staticmethod
def format(params):
format = {}
format['text'] = params[0]
return format
@staticmethod
def template(format):
template = '%s %s' % (Format.green('Comment:'), Format.italic(Format.green('%(text)s')))
return template % format
class Command408(object):
"""Comment Extra Lines"""
@staticmethod
def format(params):
format = {}
format['text'] = params[0]
return format
@staticmethod
def template(format):
template = '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;%s %s' % (Format.green(':'), Format.italic(Format.green('%(text)s')))
return template % format
class Command111(object):
"""Conditional Branch"""
@staticmethod
def format(params):
format = {}
mode = params[0]
mode_dict = {
0: 'Switch', 1: 'Variable', 2: 'Self Switch', 3: 'Timer',
4: 'Actor', 5: 'Enemy', 6: 'character', 7: 'Gold', 8: 'Item',
9: 'Weapon', 10: 'Armor', 11: 'Button', 12: 'Script'
}
format['mode'] = mode
format['mode_name'] = mode_dict[params[0]]
project = Kernel.GlobalObjects.get_value("PROJECT")
system = project.getData('System')
if mode == 0: # switch
format['switch_id'] = params[1]
format['switch_name'] = system.switches[params[1]]
if params[2] == 0:
format['switch_state'] = 'True'
else:
format['switch_state'] = 'False'
elif mode == 1: # variable
format['var_one_id'] = params[1]
format['var_one_name'] = system.variables[params[1]]
format['var_two_mode'] = params[2]
if params[2] == 0:
format['var_two_value'] = params[3]
else:
format['var_two_id'] = params[3]
format['var_two_name'] = system.variables[params[3]]
operation_dict = {0: '==', 1: '>=', 2: '&lt;=', 3: '>', 4: '&lt;', 5: '!='}
format['operation'] = operation_dict[params[4]]
elif mode == 2: # self switch
format['self_switch'] = params[1]
if params[2] == 0:
format['switch_state'] = 'True'
else:
format['switch_state'] = 'False'
elif mode == 3: # timer
format['time'] = params[1]
format['time_mode'] = params[2]
elif mode == 4: # actor
actors = project.getData('Actors')
format['actor_id'] = params[1]
format['actor_name'] = actors[params[1]].name
format['actor_mode'] = params[2]
if params[2] == 1: # name
format['actor_condition_name'] = params[3]
elif params[2] == 2: # skill
skills = project.getData('Skills')
format['skill_id'] = params[3]
format['skill_name'] = skills[params[3]].name
elif params[2] == 3: # weapon
weapons = project.getData('Weapons')
format['weapon_id'] = params[3]
format['weapon_name'] = weapons[params[3]].name
elif params[2] == 4: # armor
armors = project.getData('Armors')
format['armor_id'] = params[3]
format['armor_name'] = armors[params[3]].name
elif params[2] == 5: # state
states = project.getData('States') #system.states
format['state_id'] = params[3]
format['state_name'] = states[params[3]].name
if params[2] != 0:
format['actor_condition'] = params[3]
elif mode == 5: # enemy
format['enemy_position'] = params[1]
format['enemy_mode'] = params[2]
states = project.getData('States')
format['enemy_state_id'] = params[3]
format['enemy_state_name'] = states[params[3]].name
elif mode == 6: # character
if(params[1] & 0x80000000):
format['character_id'] = -0x100000000 + params[1]
else:
format['character_id'] = params[1]
format['character_direction'] = params[2]
elif mode == 7: # gold
format['gold_mode'] = params[2]
format['gold_value'] = params[1]
elif mode == 8: # item
items = project.getData('Items')
format['item_id'] = params[1]
format['item_name'] = items[params[1]].name
elif mode == 9: # weapon
weapons = project.getData('Weapons')
format['weapon_id'] = params[1]
format['weapon_name'] = weapons[params[1]].name
elif mode == 10: # armor
armors = project.getData('Armors')
format['armor_id'] = params[1]
format['armor_name'] = armors[params[1]].name
elif mode == 11: # button
format['button'] = params[1]
elif mode == 12:
format['script'] = params[1]
else:
pass
return format
@staticmethod
def template(format):
mode = format['mode']
template = (Format.blue('Conditional Branch: %s') % Format.bold('if')) + ' %s'
html = (Format.red('%s Missing handeler for mode [%s]') % (Format.bold('ERROR[Code 111: Conditional Branch]:'), '%(mode)s')) % format
if mode == 0: # switch
html = (Format.color('black', 'Switch [%s: %s] %s %s') % (
Format.red('%(switch_id)04d'),
Format.green('%(switch_name)s'),
Format.bold('=='),
Format.blue(Format.bold('%(switch_state)s'))
)) % format
elif mode == 1: # variable
if format['var_two_mode'] == 0:
html = ('Variable [%s: %s] %s %s' % (
Format.red('%(var_one_id)04d'),
Format.green('%(var_one_name)s'),
Format.bold('%(operation)s'),
Format.bold('%(var_two_value)s')
)) % format
else:
html = ('Variable [%s: %s] %s Variable [%s: %s]' % (
Format.red('%(var_one_id)04d'),
Format.green('%(var_one_name)s'),
Format.bold('%(operation)s'),
Format.red('%(var_two_id)04d'),
Format.green('%(var_two_name)s')
)) % format
elif mode == 2: # self switch
html = ('Self Switch %s %s %s' % (
Format.green('%(self_switch)s'),
Format.bold('=='),
Format.green('%(switch_state)s')
)) % format
elif mode == 3: # timer
if format['time_mode'] == 0:
html = ('Timer %s %s seconds' % (Format.bold('>='), Format.red('%(time)s'))) % format
else:
html = ('Timer %s %s seconds' % (Format.bold('&lt;='), Format.red('%(time)s'))) % format
elif mode == 4: # actor
if format['actor_mode'] == 0: # in party
html = ('Actor [%s: %s] %s in party' % (
Format.red('%(actor_id)s'),
Format.green('%(actor_name)s'),
Format.bold('is')
)) % format
elif format['actor_mode'] == 1: # name
html = ('Actor [%s: %s].%s %s %s' % (
Format.red('%(actor_id)s'),
Format.green('%(actor_name)s'),
Format.bold('name'),
Format.bold('=='),
Format.green('%(actor_condition_name)s')
)) % format
elif format['actor_mode'] == 2: # skill
html = ('Actor [%s: %s] Has Skill [%s: %s]' % (
Format.red('%(actor_id)s'),
Format.green('%(actor_name)s'),
Format.red('%(skill_id)04d'),
Format.green('%(skill_name)s')
)) % format
elif format['actor_mode'] == 3: # weapon
html = ('Actor [%s: %s] Has Weapon Equiped [%s: %s]' % (
Format.red('%(actor_id)s'),
Format.green('%(actor_name)s'),
Format.red('%(weapon_id)04d'),
Format.green('%(weapon_name)s')
)) % format
elif format['actor_mode'] == 4: # armor
html = ('Actor [%s: %s] Has Armor Equiped [%s: %s]' % (
Format.red('%(actor_id)s'),
Format.green('%(actor_name)s'),
Format.red('%(armor_id)04d'),
Format.green('%(armor_name)s')
)) % format
elif format['actor_mode'] == 5: # state
html = ('Actor [%s: %s] Has State [%s: %s]' % (
Format.red('%(actor_id)s'),
Format.green('%(actor_name)s'),
Format.red('%(state_id)04d'),
Format.green('%(state_name)s')
)) % format
elif mode == 5: # enemy
if format['enemy_mode'] == 0: # appear
html = ('Enemy at positon [%s] Appears' % Format.red('%(enemy_position)s')) % format
elif format['enemy_mode'] == 1: # state
html = ('Enemy at positon [%s] Has State [%s: %s]' % (
Format.red('%(enemy_position)s'),
Format.red('%(enemy_state_id)04d'),
Format.green('%(enemy_state_name)s')
)) % format
elif mode == 6: # character
directionmap = {
2: 'DOWN',
4: 'LEFT',
6: 'RIGHT',
8: 'UP'
}
format['character_direction_name'] = directionmap[format['character_direction']]
if format['character_id'] == -1:
html = ('Player %s Facing %s' % (Format.bold('is'), Format.green('%(character_direction_name)s'))) % format
elif format['character_id'] == 0:
html = ('This Event %s Facing %s' % (Format.bold('is'), Format.green('%(character_direction_name)s'))) % format
else:
html = ('Event ID [%s] %s Facing %s' % (
Format.red('%(character_id)04d'),
Format.bold('is'),
Format.green('%(character_direction_name)s')
)) % format
elif mode == 7: # gold
if format['gold_mode'] == 0:
html = ('Party Gold %s %s' % (Format.bold('>='), Format.red('%(gold_value)s'))) % format
else:
html = ('Party Gold %s %s' % (Format.bold('&lt;='), Format.red('%(gold_value)s'))) % format
elif mode == 8: # item
html = ('Party Has At Least One of Item [%s: %s]' % (Format.red('%(item_id)04d'), Format.green('%(item_name)s'))) % format
elif mode == 9: # weapon
html = ('Party Has At Least One of Weapon [%s: %s]' % (Format.red('%(weapon_id)04d'), Format.green('%(weapon_name)s'))) % format
elif mode == 10: # armor
html = ('Party Has At Least One of Armor [%s: %s]' % (Format.red('%(armor_id)04d'), Format.green('%(armor_name)s'))) % format
elif mode == 11: # button
buttonmap = {
2: 'DOWN',
4: 'LEFT',
6: 'RIGHT',
8: 'UP',
11: 'A',
12: 'B',
13: 'C',
14: 'X',
15: 'Y',
16: 'Z',
17: 'L',
18: 'R',
21: 'SHIFT',
22: 'CTRL',
23: 'ALT',
25: 'F5',
26: 'F6',
27: 'F7',
28: 'F8',
29: 'F9',
}
format['button_name'] = buttonmap[format['button']]
html = ('Button [%s] %s Pressed' % (Format.red('%(button_name)s'), Format.bold('is'))) % format
else: # script
html = 'Script: '
lines = format['script'].split('\n')
html += Format.italic(Kernel.escapeHTML(lines[0]))
body = template % html
return body
class Command411(object):
"""Else"""
@staticmethod
def format(params):
format = {}
return format
@staticmethod
def template(format):
return '%s' % (Format.blue('Else'))
class Command112(object):
"""Loop"""
@staticmethod
def format(params):
format = {}
return format
@staticmethod
def template(format):
return '%s' % (Format.blue('Loop'))
class Command413(object):
"""Repeat Above"""
@staticmethod
def format(params):
format = {}
return format
@staticmethod
def template(format):
return '%s' % (Format.blue('Repeat Above'))
class Command113(object):
"""Break Loop"""
@staticmethod
def format(params):
format = {}
return format
@staticmethod
def template(format):
return '%s' % (Format.blue('Break Loop'))
class Command115(object):
"""Exit Event Processing"""
@staticmethod
def format(params):
format = {}
return format
@staticmethod
def template(format):
return '%s' % (Format.red(Format.bold('Exit Event Processing')))
class Command116(object):
"""Erase Event"""
@staticmethod
def format(params):
format = {}
return format
@staticmethod
def template(format):
return '%s' % (Format.red(Format.bold('Erase Event')))
class Command117(object):
"""Call Common Event"""
@staticmethod
def format(params):
format = {}
format['commonevent_id'] = params[0]
return format
@staticmethod
def template(format):
template = '%s: ID [%s]' % (Format.red('Call Common Event'), Format.red(Format.bold('%(commonevent_id)s')))
return template % format
class Command118(object):
"""Label"""
@staticmethod
def format(params):
format = {}
format['label_name'] = params[0]
return format
@staticmethod
def template(format):
template = '%s: %s' % (Format.blue('Label'), Format.green('%(label_name)s'))
return template % format
class Command119(object):
"""Jump to Label"""
@staticmethod
def format(params):
format = {}
format['jump_to_name'] = params[0]
return format
@staticmethod
def template(format):
template = '%s: %s' % (Format.blue('Jump to Label'), Format.green(Format.italic('%(jump_to_name)s')))
return template % format
class Command121(object):
"""Control Switches"""
@staticmethod
def format(params):
format = {}
project = Kernel.GlobalObjects.get_value("PROJECT")
system = project.getData('System')
format['params'] = params
format['switch_1_id'] = params[0]
format['switch_1_name'] = system.switches[params[0]]
format['switch_2_id'] = params[1]
format['switch_2_name'] = system.switches[params[1]]
if params[2] == 0:
format['switch_state'] = 'True'
else:
format['switch_state'] = 'False'
return format
@staticmethod
def template(format):
if format['switch_2_id'] == format['switch_1_id']: # only modifying 1 var
template = '%s Switch [%s: %s] = %s' % (
Format.red('Control Switch:'),
Format.red('%(switch_1_id)s'),
Format.green('%(switch_1_name)s'),
Format.blue(Format.bold('%(switch_state)s'))
)
else:
template = '%s [%s: %s] -> [%s:%s] = %s' % (
Format.red('Control Switchs:'),
Format.red('%(switch_1_id)s'),
Format.green('%(switch_1_name)s'),
Format.red('%(switch_2_id)s'),
Format.green('%(switch_2_name)s'),
Format.blue(Format.bold('%(switch_state)s'))
)
return template % format
class Command122(object):
"""Control Variables"""
@staticmethod
def format(params):
format = {}
format['batch_low'] = params[0]
format['batch_high'] = params[1]
operator_dict = {
0: '= ', 1: '+= ', 2: '-= ', 3: '*= ', 4: '/= ', 5: '%= '
}
format['operation'] = operator_dict[params[2]]
format['operand'] = params[3]
if(params[4] & 0x80000000):
format['op_param1'] = -0x100000000 + params[4]
else:
format['op_param1'] = params[4]
if params[3] == 2 or params[3] == 4 or params[3] == 5 or params[3] == 6:
if(params[5] & 0x80000000):
format['op_param2'] = -0x100000000 + params[5]
else:
format['op_param2'] = params[5]
return format
@staticmethod
def template(format):
template = '%s: ' % (Format.red('Control Variables'))
project = Kernel.GlobalObjects.get_value("PROJECT")
system = project.getData('System')
# Draw variable or batch
if format['batch_low'] == format['batch_high']:
format['var_name'] = system.variables[format['batch_low']]
template += '[%s: %s] ' % (Format.bold('%(batch_low)04d'), Format.red('%(var_name)s'))
else:
template += '[%s..%s] ' % (Format.red('%(batch_low)04d'), Format.red('%(batch_high)04d'))
# Draw operation symbol
template += '%s' % (Format.red('%(operation)s'))
# Draw operand
if format['operand'] == 0: # constant
template += '%s' % (Format.red(Format.italic('%(op_param1)s')))
elif format['operand'] == 1: # variable
format['opr_var_name'] = system.variables[format['op_param1']]
template += '[%s: %s] ' % (Format.bold('%(op_param1)04d'), Format.red('%(opr_var_name)s'))
elif format['operand'] == 2: # random number
template += '%s(%s, %s)' % (Format.bold('rand'), Format.red('%(op_param1)s'), Format.red('%(op_param2)s'))
elif format['operand'] == 3: # item
items = project.getData('Items')
format['item_name'] = items[format['op_param1']].name
template += '[%s: %s] In Inventory' % (Format.red('%(op_param1)04d'), Format.red('%(item_name)s'))
elif format['operand'] == 4: # actor
actors = project.getData('Actors')
format['actor_name'] = actors[format['op_param1']].name
template += '[%s: %s].' % (Format.red('%(op_param1)04d'), Format.red('%(actor_name)s'))
if format['op_param2'] == 0: # Level
template += '%s' % (Format.bold('level'))
elif format['op_param2'] == 1: # EXP
template += '%s' % (Format.bold('exp'))
elif format['op_param2'] == 2: # HP
template += '%s' % (Format.bold('hp'))
elif format['op_param2'] == 3: # SP
template += '%s' % (Format.bold('sp'))
elif format['op_param2'] == 4: # MaxHP
template += '%s' % (Format.bold('maxhp'))
elif format['op_param2'] == 5: # MaxSP
template += '%s' % (Format.bold('maxsp'))
elif format['op_param2'] == 6: # STR
template += '%s' % (Format.bold('str'))
elif format['op_param2'] == 7: # DEX
template += '%s' % (Format.bold('dex'))
elif format['op_param2'] == 8: # AGI
template += '%s' % (Format.bold('agi'))
elif format['op_param2'] == 9: # INT
template += '%s' % (Format.bold('int'))
elif format['op_param2'] == 10: # ATK
template += '%s' % (Format.bold('atk'))
elif format['op_param2'] == 11: # PDEF
template += '%s' % (Format.bold('pdef'))
elif format['op_param2'] == 12: # MDEF
template += '%s' % (Format.bold('mdef'))
elif format['op_param2'] == 13: # EVA
template += '%s' % (Format.bold('eva'))
elif format['operand'] == 5: # enemy
template += 'Enemy at positon [%s].' % (Format.red('%(op_param1)s'))
if format['op_param2'] == 0:
template += '%s' % (Format.bold('hp'))
elif format['op_param2'] == 1: # SP
template += '%s' % (Format.bold('sp'))
elif format['op_param2'] == 2: # MaxHP
template += '%s' % (Format.bold('maxhp'))
elif format['op_param2'] == 3: # MaxSP
template += '%s' % (Format.bold('maxsp'))
elif format['op_param2'] == 4: # STR
template += '%s' % (Format.bold('str'))
elif format['op_param2'] == 5: # DEX
template += '%s' % (Format.bold('dex'))
elif format['op_param2'] == 6: # AGI
template += '%s' % (Format.bold('agi'))
elif format['op_param2'] == 7: # INT
template += '%s' % (Format.bold('int'))
elif format['op_param2'] == 8: # PDEF
template += '%s' % (Format.bold('pdef'))
elif format['op_param2'] == 9: # MDEF
template += '%s' % (Format.bold('mdef'))
elif format['op_param2'] == 10: # EVA
template += '%s' % (Format.bold('eva'))
elif format['operand'] == 6: # character
if format['op_param1'] == -1: # player
template += '[Player].'
elif format['op_param1'] == 0: # this event
template += '[This Event].'
else:
template += 'Event[%s].' % (Format.red('%(op_param1)04d'))
# Choice
if format['op_param2'] == 0: # Map X
template += '%s' % (Format.bold('map_x'))
elif format['op_param2'] == 1: # Map Y
template += '%s' % (Format.bold('map_y'))
elif format['op_param2'] == 2: # Direction
template += '%s' % (Format.bold('direction'))
elif format['op_param2'] == 3: # Screen X
template += '%s' % (Format.bold('screen_x'))
elif format['op_param2'] == 4: # Screen Y
template += '%s' % (Format.bold('screen_y'))
elif format['op_param2'] == 5: # Terrain Tag
template += '%s' % (Format.bold('terrain_tag'))
elif format['operand'] == 7: # other
if format['op_param1'] == 0: # Map ID
template += '%s' % (Format.bold('Map ID'))
elif format['op_param1'] == 1: # Party Members
template += '%s' % (Format.bold('Party Members'))
elif format['op_param1'] == 2: # Gold
template += '%s' % (Format.bold('Gold'))
elif format['op_param1'] == 3: # Steps
template += '%s' % (Format.bold('Steps'))
elif format['op_param1'] == 4: # Play Time
template += '%s' % (Format.bold('Play Time'))
elif format['op_param1'] == 5: # Timer
template += '%s' % (Format.bold('Timer'))
elif format['op_param1'] == 6: # Save Count
template += '%s' % (Format.bold('Save Count'))
return template % format
class Command123(object):
"""Control Self Switch"""
@staticmethod
def format(params):
format = {}
format['self_switch'] = params[0]
if params[1] == 0:
format['switch_state'] = 'True'
else:
format['switch_state'] = 'False'
return format
@staticmethod
def template(format):
template = '%s: %s %s %s' % (Format.red('Control Self Switch'),
Format.green('%(self_switch)s'),
Format.bold('='),
Format.green('%(switch_state)s'))
return template % format
class Command124(object):
"""Control Timer"""
@staticmethod
def format(params):
format = {}
format['timer_state'] = params[0]
if params[0] == 0:
format['timer_countdown'] = params[1]
return format
@staticmethod
def template(format):
if format['timer_state'] == 0:
template = '%s: %s (%s seconds)' % (Format.bold('Control Timer'),
Format.red(Format.italic('Start')),
Format.red('%(timer_countdown)s'))
else:
template = '%s: %s' % (Format.bold('Control Timer'), Format.red(Format.italic('Stop')))
return template % format
class Command125(object):
"""Change Gold"""
@staticmethod
def format(params):
format = {}
operation = {0: '+', 1: '-'}
format['operation'] = operation[params[0]]
format['operand_type'] = params[1]
format['operand'] = params[2]
return format
@staticmethod
def template(format):
template = '%s: %s' % (Format.italic(Format.green('Change Gold')), Format.bold('%(operation)s'))
if format['operand_type'] == 0: # constant
template += '%s' % (Format.bold(Format.red('%(operand)s')))
else: # variable
project = Kernel.GlobalObjects.get_value("PROJECT")
system = project.getData('System')
format['var_name'] = system.variables[format['operand']]
template += 'Variable [%s: %s]' % (Format.bold('%(operand)04d'), Format.red('%(var_name)s'))
return template % format
class Command126(object):
"""Change Items"""
@staticmethod
def format(params):
format = {}
format['item_id'] = params[0]
operation = {0: '+', 1: '-'}
format['operation'] = operation[params[1]]
format['operand_type'] = params[2]
format['operand'] = params[3]
return format
@staticmethod
def template(format):
project = Kernel.GlobalObjects.get_value("PROJECT")
items = project.getData('Items')
format['item_name'] = items[format['item_id']].name
template = '%s: [%s: %s], %s' % (Format.italic(Format.green('Change Items')), Format.blue('%(item_id)04d'),
Format.blue('%(item_name)s'), Format.bold('%(operation)s'))
if format['operand_type'] == 0: # constant
template += '%s' % (Format.bold(Format.red('%(operand)s')))
else: # variable
system = project.getData('System')
format['var_name'] = system.variables[format['operand']]
template += 'Variable [%s: %s]' % (Format.bold('%(operand)04d'), Format.red('%(var_name)s'))
return template % format
class Command127(object):
"""Change Weapons"""
@staticmethod
def format(params):
format = {}
format['weapon_id'] = params[0]
operation = {0: '+', 1: '-'}
format['operation'] = operation[params[1]]
format['operand_type'] = params[2]
format['operand'] = params[3]
return format
@staticmethod
def template(format):
project = Kernel.GlobalObjects.get_value("PROJECT")
weapons = project.getData('Weapons')
format['weapon_name'] = weapons[format['weapon_id']].name
template = '%s: [%s: %s], %s' % (Format.italic(Format.green('Change Weapons')), Format.blue('%(weapon_id)04d'),
Format.blue('%(weapon_name)s'), Format.bold('%(operation)s'))
if format['operand_type'] == 0: # constant
template += '%s' % (Format.bold(Format.red('%(operand)s')))
else: # variable
system = project.getData('System')
format['var_name'] = system.variables[format['operand']]
template += 'Variable [%s: %s]' % (Format.bold('%(operand)04d'), Format.red('%(var_name)s'))
return template % format
class Command128(object):
"""Change Armor"""
@staticmethod
def format(params):
format = {}
format['armor_id'] = params[0]
operation = {0: '+', 1: '-'}
format['operation'] = operation[params[1]]
format['operand_type'] = params[2]
format['operand'] = params[3]
return format
@staticmethod
def template(format):
project = Kernel.GlobalObjects.get_value("PROJECT")
armors = project.getData('Armors')
format['armor_name'] = armors[format['armor_id']].name
template = '%s: [%s: %s], %s' % (Format.italic(Format.green('Change Armors')), Format.blue('%(armor_id)04d'),
Format.blue('%(armor_name)s'), Format.bold('%(operation)s'))
if format['operand_type'] == 0: # constant
template += '%s' % (Format.bold(Format.red('%(operand)s')))
else: # variable
system = project.getData('System')
format['var_name'] = system.variables[format['operand']]
template += 'Variable [%s: %s]' % (Format.bold('%(operand)04d'), Format.red('%(var_name)s'))
return template % format
class Command129(object):
"""Change Party Member"""
@staticmethod
def format(params):
format = {}
format['actor_id'] = params[0]
project = Kernel.GlobalObjects.get_value("PROJECT")
actors = project.getData('Actors')
format['actor_name'] = actors[params[0]].name
operation = {0: 'Add', 1: 'Remove'}
format['operation'] = operation[params[1]]
format['initialize'] = params[2]
return format
@staticmethod
def template(format):
template = '%s: %s Actor[%s: %s]' % (Format.blue('Change Party Member'), Format.red('%(operation)s'),
Format.red('%(actor_id)04d'), Format.red('%(actor_name)s'))
if format['initialize'] == 1: #Initialize Actor
template += ', Initialize'
return template % format
class Command131(object):
"""Change Windowskin"""
@staticmethod
def format(params):
format = {}
format['winskin_name'] = params[0]
return format
@staticmethod
def template(format):
template = '%s: %s' % (Format.bold('Change Windowskin'), Format.green('%(winskin_name)s'))
return template % format
class Command132(object):
"""Change Battle BGM"""
@staticmethod
def format(params):
format = {}
format['params'] = params
format['se_file'] = params[0]
return format
@staticmethod
def template(format):
template = '%s %s' % (
Format.color('#348781', 'Change Battle BGM:'),
Format.audioFile(format['se_file'])
)
return template % format
class Command133(object):
"""Change Battle End ME"""
@staticmethod
def format(params):
format = {}
format['params'] = params
format['se_file'] = params[0]
return format
@staticmethod
def template(format):
template = '%s %s' % (
Format.color('#348781', 'Change Battle End ME:'),
Format.audioFile(format['se_file'])
)
return template % format
class Command134(object):
"""Change Save Access"""
@staticmethod
def format(params):
format = {}
format['can_save'] = params[0]
return format
@staticmethod
def template(format):
if format['can_save'] == 0:
return '%s: %s' % (Format.bold(Format.blue('Change Save Access')), Format.red('Disabled'))
else:
return '%s: %s' % (Format.bold(Format.blue('Change Save Access')), Format.green('Enabled'))
class Command135(object):
"""Change Menu Access"""
@staticmethod
def format(params):
format = {}
format['access_menu'] = params[0]
return format
@staticmethod
def template(format):
if format['access_menu'] == 0:
return '%s: %s' % (Format.bold(Format.blue('Change Menu Access')), Format.red('Disabled'))
else:
return '%s: %s' % (Format.bold(Format.blue('Change Menu Access')), Format.green('Enabled'))
class Command136(object):
"""Change Encounter"""
@staticmethod
def format(params):
format = {}
format['can_encounter'] = params[0]
return format
@staticmethod
def template(format):
if format['can_encounter'] == 0:
return '%s: %s' % (Format.bold(Format.blue('Change Encounter')), Format.red('Disabled'))
else:
return '%s: %s' % (Format.bold(Format.blue('Change Encounter')), Format.green('Enabled'))
class Command201(object):
"""Transfer Player"""
@staticmethod
def format(params):
format = {}
format['appoint'] = params[0]
format['map_id'] = params[1]
format['x_coord'] = params[2]
format['y_coord'] = params[3]
direction = {0: 'Retain', 2: 'Down', 4: 'Left', 6: 'Right', 8: 'Up'}
format['direction'] = direction[params[4]]
boolean_dict = {0: 'True', 1: 'False'}
format['fade'] = boolean_dict[params[5]]
return format
@staticmethod
def template(format):
template = '%s: ' % (Format.blue('Transfer Player'))
if format['appoint'] == 0:
template += 'Map ID (%s) at (%s, %s), ' % (Format.red('%(map_id)s'),
Format.blue('%(x_coord)s'), Format.blue('%(y_coord)s'))
else:
template += '[Variables] Map ID ([%s]) at ([%s], [%s]), ' % (Format.red('%(map_id)04d'),
Format.blue('%(x_coord)04d'), Format.blue('%(y_coord)04d'))
template += 'Direction %s %s, Fade %s %s' % (Format.bold('='), Format.italic('%(direction)s'),
Format.bold('='), Format.blue(Format.bold('%(fade)s')))
return template % format
class Command202(object):
"""Set Event Location"""
@staticmethod
def format(params):
format = {}
format['event_id'] = params[0]
format['operation'] = params[1]
if params[1] == 0:
format['x_pos'] = params[2]
format['y_pos'] = params[3]
elif params[1] == 1:
format['x_variable'] = params[2]
format['y_variable'] = params[3]
else:
format['switch_event_id'] = params[2]
direction_dict = {0: 'Retain', 2: 'Down', 4: 'Left', 6: 'Right', 8: 'Up'}
format['direction'] = direction_dict[params[4]]
return format
@staticmethod
def template(format):
template = '%s: Event ID [%s], ' % (Format.bold('Set Event Location'), Format.green('%(event_id)03d'))
if format['operation'] == 0:
template += '(%s, %s), ' % (Format.bold('%(x_pos)s'), Format.bold('%(y_pos)s'))
elif format['operation'] == 1:
template += 'Variables ([%s], [%s]), ' % (Format.red('%(x_variable)03d'), Format.red('%(y_variable)03d'))
else:
template += 'Switch with Event ID [%s], ' % Format.green('%(switch_event_id)03d')
template += 'Direction = %s' % Format.bold('%(direction)s')
return template % format
class Command203(object):
"""Scroll Map"""
@staticmethod
def format(params):
format = {}
direction_dict = {0: 'Down', 1: 'Left', 2: 'Right', 3: 'Up'}
format['direction'] = direction_dict[params[0]]
format['distance'] = params[1]
format['speed'] = params[2]
return format
@staticmethod
def template(format):
template = '%s: %s by %s tiles, Speed = %s' % (Format.bold('Scroll Map'), Format.blue('%(direction)s'),
Format.green('%(distance)s'), Format.red('%(speed)s'))
return template % format
class Command204(object):
"""Change Map Settings"""
@staticmethod
def format(params):
format = {}
format['operation'] = params[0]
format['filename'] = params[1]
if params[0] == 0:
format['panorama_hue'] = params[2]
elif params[0] == 1:
format['fog_hue'] = params[2]
format['fog_opacity'] = params[3]
blend_dict = {0: 'Normal', 1: 'Add', 2: 'Sub'}
format['fog_blend_type'] = blend_dict[params[4]]
format['fog_zoom'] = params[5]
if(params[6] & 0x80000000):
format['fog_sx'] = -0x100000000 + params[6]
else:
format['fog_sx'] = params[6]
if(params[7] & 0x80000000):
format['fog_sy'] = -0x100000000 + params[7]
else:
format['fog_sy'] = params[7]
return format
@staticmethod
def template(format):
template = '%s: ' % Format.bold('Change Map Settings')
if format['operation'] == 0:
template += '[%s] %s, Hue = %s' % (Format.blue('Panorama'), Format.italic('%(filename)s'), Format.bold('%(panorama_hue)s'))
elif format['operation'] == 1:
template += '[%s] %s, Hue = %s, Opacity = %s, Blend = %s, Zoom = %s, Scroll Speed = (%s, %s)' % (Format.blue('Fog'),
Format.italic('%(filename)s'), Format.bold('%(fog_hue)s'), Format.bold('%(fog_opacity)s'), Format.bold('%(fog_blend_type)s'),
Format.bold('%(fog_zoom)s'), Format.bold('%(fog_sx)s'), Format.bold('%(fog_sy)s'))
else:
template += '[%s] %s' % (Format.blue('Battleback'), Format.italic('%(filename)s'))
return template % format
class Command205(object):
"""Change Fog Color Tone"""
@staticmethod
def format(params):
format = {}
format['color'] = params[0]
format['time'] = params[1]
return format
@staticmethod
def template(format):
template = "%s %s %s %s %s" % (
Format.color('#808000', 'Change Fog Color Tone:'),
Format.colorObj(format['color']),
Format.blue(Format.bold('in')),
Format.red('%(time)s'),
Format.color('#808000', 'Frames')
)
return template % format
class Command206(object):
"""Change Fog Opacity"""
@staticmethod
def format(params):
format = {}
format['opacity'] = params[0]
format['time'] = params[1]
return format
@staticmethod
def template(format):
return '%s: Opacity = %s, Time = %s frames' % (Format.bold('Change Fog Opacity'), Format.blue('%(opacity)s'), Format.bold('%(time)s'))
class Command207(object):
"""Show Animation"""
@staticmethod
def format(params):
format = {}
project = Kernel.GlobalObjects.get_value("PROJECT")
animations = project.getData('Animations')
if(params[0] & 0x80000000):
format['target_event'] = -0x100000000 + params[0]
else:
format['target_event'] = params[0]
format['animation_id'] = params[1]
format['animation_name'] = animations[params[1]]
return format
@staticmethod
def template(format):
template = '%s: ' % Format.bold('Show Animation')
if format['target_event'] == -1:
template += '%s' % Format.blue('Player')
elif format['target_event'] == 0:
template += '%s' % Format.blue('This Event')
else:
template += 'Event ID [%s]' % Format.blue('%(target_event)s')
template += '[%s: %s]' % (Format.green('%(animation_id)03d'), Format.red('%(animation_name)s'))
return template % format
class Command208(object):
"""Change Transparent Flag"""
@staticmethod
def format(params):
format = {}
flags_dict = {0: 'Transparent', 1: 'Normal'}
format['trans_flag'] = flags_dict[params[0]]
return format
@staticmethod
def template(format):
return '%s: %s' % (Format.bold('Change Transparent Flag'), Format.italic('%(trans_flag)s'))
# ==================================================================================
# Saving the best for last--oh boy
# ==================================================================================
class Command209(object):
"""Set Move Route"""
@staticmethod
def format(params):
format = {}
return format
@staticmethod
def template(format):
return ''
class Command210(object):
"""Wait for Move's Completion"""
@staticmethod
def format(params):
format = {}
return format
@staticmethod
def template(format):
return '%s' % (Format.bold('Wait for Move\'s Completion'))
class Command221(object):
"""Prepare for Transition"""
@staticmethod
def format(params):
format = {}
return format
@staticmethod
def template(format):
return '%s' % (Format.bold('Prepare for Transition'))
class Command222(object):
"""Execute Transition"""
@staticmethod
def format(params):
format = {}
format['filename'] = params[0]
return format
@staticmethod
def template(format):
template = '%s: %s' % (Format.bold('Execute Transition'), Format.green('%(filename)s'))
class Command223(object):
"""Change Screen Color Tone"""
@staticmethod
def format(params):
format = {}
format['screen_color'] = params[0]
format['screen_time'] = params[1]
return format
@staticmethod
def template(format):
template = "%s %s %s %s %s" % (
Format.color('#808000', 'Change Screen Color Tone:'),
Format.colorObj(format['screen_color']),
Format.blue(Format.bold('in')),
Format.red('%(screen_time)s'),
Format.color('#808000', 'Frames')
)
return template % format
class Command224(object):
"""Screen Flash"""
@staticmethod
def format(params):
format = {}
format['params'] = params
format['screen_color'] = params[0]
format['screen_time'] = params[1]
return format
@staticmethod
def template(format):
template = "%s %s %s %s %s" % (
Format.color('#808000', 'Screen Flash:'),
Format.colorObj(format['screen_color']),
Format.blue(Format.bold('in')),
Format.red('%(screen_time)s'),
Format.color('#808000', 'Frames')
)
return template % format
class Command225(object):
"""Screen Shake"""
@staticmethod
def format(params):
format = {}
format['power'] = params[0]
format['speed'] = params[1]
format['time'] = params[2]
return format
@staticmethod
def template(format):
template = "%s Power = %s, Speed = %s, Time = %s frames" % (
Format.color('#808000', 'Shake Screen:'),
Format.bold('%(power)s'),
Format.bold('%(speed)s'),
Format.bold('%(time)s')
)
return template % format
class Command231(object):
"""Show Picture"""
@staticmethod
def format(params):
format = {}
return format
@staticmethod
def template(format):
return ''
class Command232(object):
"""Move Picture"""
@staticmethod
def format(params):
format = {}
return format
@staticmethod
def template(format):
return ''
class Command233(object):
"""Rotate Picture"""
@staticmethod
def format(params):
format = {}
format['picture_num'] = params[0]
if(params[1] & 0x80000000):
format['speed'] = -0x100000000 + params[1]
else:
format['speed'] = params[1]
return format
@staticmethod
def template(format):
return '%s: Picture \#%s, Speed = %s' % (Format.bold('Rotate Picture'), Format.green('%(picture_num)s'), Format.bold('%(speed)s'))
class Command234(object):
"""Change Picture Color Tone"""
@staticmethod
def format(params):
format = {}
format['picture_num'] = params[0]
format['color'] = params[1]
format['frames'] = params[2]
return format
@staticmethod
def template(format):
template = '%s: Picture \#%s, %s, Time = %s frames' % (Format.bold('Change Picture Color Tone'), Format.green('%(picture_num)s'),
Format.colorObj(format['color']), Format.bold('%(frames)s'))
return template % format
class Command235(object):
"""Erase Picture"""
@staticmethod
def format(params):
format = {}
format['picture_num'] = params[0]
return format
@staticmethod
def template(format):
return '%s: Picture \#%s' % (Format.bold('Erase Picture'), Format.green('%(picture_num)s'))
class Command236(object):
"""Set Weather Effects"""
@staticmethod
def format(params):
format = {}
weather_dict = {0: 'None', 1: 'Rain', 2: 'Storm', 3: 'Snow'}
format['weather'] = weather_dict[params[0]]
format['power'] = params[1]
format['time'] = params[2]
return format
@staticmethod
def template(format):
template = '%s: %s, Power = %s, Time = %s frames' % (Format.blue('Set Weather Effects'), Format.bold('%(weather)s'),
Format.bold('%(power)s'), Format.bold('%(time)s'))
return template % format
class Command241(object):
"""Play BGM"""
@staticmethod
def format(params):
format = {}
format['params'] = params
format['bgm_file'] = params[0]
return format
@staticmethod
def template(format):
template = '%s %s' % (
Format.color('#348781', 'Play BGM:'),
Format.audioFile(format['bgm_file'])
)
return template % format
class Command242(object):
"""Fade Out BGM"""
@staticmethod
def format(params):
format = {}
format['fade_time'] = params[0]
return format
@staticmethod
def template(format):
template = '%s %s second(s)' % (Format.color('#348781', 'Fade Out BGM:'), Format.bold('%(fade_time)s'))
return template % format
class Command245(object):
"""Play BGS"""
@staticmethod
def format(params):
format = {}
format['params'] = params
format['bgs_file'] = params[0]
return format
@staticmethod
def template(format):
template = '%s %s' % (
Format.color('#348781', 'Play BGS:'),
Format.audioFile(format['bgs_file'])
)
return template % format
class Command246(object):
"""Fade Out BGS"""
@staticmethod
def format(params):
format = {}
format['fade_time'] = params[0]
return format
@staticmethod
def template(format):
template = '%s %s second(s)' % (Format.color('#348781', 'Fade Out BGS:'), Format.bold('%(fade_time)s'))
return template % format
class Command247(object):
"""Memorize BGM/BGS"""
@staticmethod
def format(params):
format = {}
return format
@staticmethod
def template(format):
return '%s' % (Format.bold('Memorize BGM/BGS'))
class Command248(object):
"""Restore BGM/BGS"""
@staticmethod
def format(params):
format = {}
return format
@staticmethod
def template(format):
return '%s' % (Format.bold('Restore BGM/BGS'))
class Command249(object):
"""Play ME"""
@staticmethod
def format(params):
format = {}
format['params'] = params
format['me_file'] = params[0]
return format
@staticmethod
def template(format):
template = '%s %s' % (
Format.color('#348781', 'Play ME:'),
Format.audioFile(format['me_file'])
)
return template % format
class Command250(object):
"""Play SE"""
@staticmethod
def format(params):
format = {}
format['params'] = params
format['se_file'] = params[0]
return format
@staticmethod
def template(format):
template = '%s %s' % (
Format.color('#348781', 'Play SE:'),
Format.audioFile(format['se_file'])
)
return template % format
class Command251(object):
"""Stop SE"""
@staticmethod
def format(params):
format = {}
return format
@staticmethod
def template(format):
return '%s' % (Format.bold('Stop SE'))
class Command301(object):
"""Battle Processing"""
@staticmethod
def format(params):
format = {}
project = Kernel.GlobalObjects.get_value("PROJECT")
troops = project.getData('Troops')
format['troop_id'] = params[0]
format['troop_name'] = troops[params[0]].name
return format
@staticmethod
def template(format):
template = '%s: [%s: %s]' % (Format.red('Battle Processing'), Format.green('%(troop_id)04d'), Format.blue('%(troop_name)s'))
return template % format
class Command601(object):
"""If Win"""
@staticmethod
def format(params):
format = {}
return format
@staticmethod
def template(format):
return '%s' % Format.bold(Format.blue('If Win'))
class Command602(object):
"""If Escape"""
@staticmethod
def format(params):
format = {}
return format
@staticmethod
def template(format):
return '%s' % Format.bold(Format.blue('If Escape'))
class Command603(object):
"""If Lose"""
@staticmethod
def format(params):
format = {}
return format
@staticmethod
def template(format):
return '%s' % Format.bold(Format.blue('If Lose'))
class Command604(object):
"""Battle Branch End"""
@staticmethod
def format(params):
format = {}
return format
@staticmethod
def template(format):
return '%s' % Format.bold(Format.blue('Battle Branch End'))
class Command302(object):
"""Shop Processing"""
@staticmethod
def format(params):
format = {}
format['params'] = params
format['shop_item_type'] = params[0]
project = Kernel.GlobalObjects.get_value("PROJECT")
if params[0] == 0:
items = project.getData('Items')
format['shop_item'] = items[params[1]]
elif params[0] == 1:
weapons = project.getData('Weapons')
format['shop_item'] = weapons[params[1]]
elif params[0] == 2:
armors = project.getData('Armors')
format['shop_item'] = armors[params[1]]
else:
pass
return format
@staticmethod
def template(format):
if format['shop_item_type'] == 0:
item = Format.item(format['shop_item'])
elif format['shop_item_type'] == 1:
item = Format.weapon(format['shop_item'])
elif format['shop_item_type'] == 2:
item = Format.armor(format['shop_item'])
else:
item = Format.red(Format.bold('Error:') + (' Unknown Item type [%s]' % format['shop_item_type']))
template = '%s %s' % (
Format.color('#F88017', 'Shop:'),
item
)
return template
class Command605(object):
"""Shop Goods Extra Line"""
@staticmethod
def format(params):
format = {}
format['params'] = params
format['shop_item_type'] = params[0]
project = Kernel.GlobalObjects.get_value("PROJECT")
if params[0] == 0:
items = project.getData('Items')
format['shop_item'] = items[params[1]]
elif params[0] == 1:
weapons = project.getData('Weapons')
format['shop_item'] = weapons[params[1]]
elif params[0] == 2:
armors = project.getData('Armors')
format['shop_item'] = armors[params[1]]
else:
pass
return format
@staticmethod
def template(format):
if format['shop_item_type'] == 0:
item = Format.item(format['shop_item'])
elif format['shop_item_type'] == 1:
item = Format.weapon(format['shop_item'])
elif format['shop_item_type'] == 2:
item = Format.armor(format['shop_item'])
else:
item = Format.red(Format.bold('Error:') + (' Unknown Item type [%s]' % format['shop_item_type']))
template = '%s %s' % (
Format.color('#F88017', '&nbsp;&nbsp;&nbsp;&nbsp;:'),
item
)
return template
class Command303(object):
"""Name Input Processing"""
@staticmethod
def format(params):
format = {}
project = Kernel.GlobalObjects.get_value("PROJECT")
actors = project.getData('Actors')
format['actor_id'] = params[0]
format['actor_name'] = actors[params[0]].name
format['characters'] = params[1]
return format
@staticmethod
def template(format):
template = '%s: Actor [%s: %s], %s characters' % (Format.color('#F88017', 'Name Input Processing'),
Format.red('%(actor_id)04d'), Format.green('%(actor_name)s'),
Format.bold('%(characters)s'))
return template % format
class Command311(object):
"""Change HP"""
@staticmethod
def format(params):
format = {}
format['party_target'] = params[0]
operator_dict = {0: '+=', 1: '-='}
format['operation'] = operator_dict[params[1]]
format['operand'] = params[2]
format['const_or_var'] = params[3]
format['allow_ko'] = params[4]
return format
@staticmethod
def template(format):
project = Kernel.GlobalObjects.get_value("PROJECT")
template = '%s: ' % Format.blue('Change HP')
if format['party_target'] == 0: # Entire Party
template += '%s ' % Format.bold('Entire Party')
else: # Specific Actor
actors = project.getData('Actors')
format['actor_name'] = actors[format['party_target']].name
template += '[%s: %s] ' % (Format.bold('%(party_target)04d'), Format.red('%(actor_name)s'))
template += '%s ' % Format.bold('%(operation)s')
if format['operand'] == 0: # Constant
template += '%s' % Format.blue('%(const_or_var)s')
else: # Variable
system = project.getData('System')
format['var_name'] = system.variables[format['const_or_var']]
template += 'Variable [%s: %s]' % (Format.bold('%(const_or_var)04d'), Format.blue('%(var_name)s'))
if format['allow_ko'] == 1: # Can KO
template += ', %s' % (Format.bold('Allow KO'))
return template % format
class Command312(object):
"""Change SP"""
@staticmethod
def format(params):
format = {}
format['party_target'] = params[0]
operator_dict = {0: '+=', 1: '-='}
format['operation'] = operator_dict[params[1]]
format['operand'] = params[2]
format['const_or_var'] = params[3]
return format
@staticmethod
def template(format):
project = Kernel.GlobalObjects.get_value("PROJECT")
template = '%s: ' % Format.blue('Change SP')
if format['party_target'] == 0: # Entire Party
template += '%s ' % Format.bold('Entire Party')
else: # Specific Actor
actors = project.getData('Actors')
format['actor_name'] = actors[format['party_target']].name
template += '[%s: %s] ' % (Format.bold('%(party_target)04d'), Format.red('%(actor_name)s'))
template += '%s ' % Format.bold('%(operation)s')
if format['operand'] == 0: # Constant
template += '%s' % Format.blue('%(const_or_var)s')
else: # Variable
system = project.getData('System')
format['var_name'] = system.variables[format['const_or_var']]
template += 'Variable [%s: %s]' % (Format.bold('%(const_or_var)04d'), Format.blue('%(var_name)s'))
return template % format
class Command313(object):
"""Change State"""
@staticmethod
def format(params):
format = {}
format['party_target'] = params[0]
operator_dict = {0: '+', 1: '-'}
format['operation'] = operator_dict[params[1]]
project = Kernel.GlobalObjects.get_value("PROJECT")
states = project.getData('States')
format['state_id'] = params[2]
format['state_name'] = states[format['state_id']].name
return format
@staticmethod
def template(format):
project = Kernel.GlobalObjects.get_value("PROJECT")
template = '%s: ' % Format.blue('Change State')
if format['party_target'] == 0: # Entire Party
template += '%s ' % Format.bold('Entire Party')
else: # Specific Actor
actors = project.getData('Actors')
format['actor_name'] = actors[format['party_target']].name
template += '[%s: %s] ' % (Format.bold('%(party_target)04d'), Format.red('%(actor_name)s'))
template += '%s [%s: %s]' % (Format.bold('%(operation)s'), Format.bold('%(state_id)04d'), Format.green('%(state_name)s'))
return template % format
class Command314(object):
"""Recover All"""
@staticmethod
def format(params):
format = {}
project = Kernel.GlobalObjects.get_value("PROJECT")
actors = project.getData('Actors')
format['params'] = params
format['actor_id'] = params[0]
if params[0] > 0:
format['actor_name'] = actors[params[0]].name
return format
@staticmethod
def template(format):
if format['actor_id'] <= 0:
actor = 'Entire Party'
else:
actor = 'Actor [%s: %s]' % (Format.red('%(actor_id)03d'), Format.green('%(actor_name)s'))
template = '%s %s' % (
Format.color('#3BB9FF', 'Recover All:'),
actor
)
return template % format
class Command315(object):
"""Change EXP"""
@staticmethod
def format(params):
format = {}
format['party_target'] = params[0]
operator_dict = {0: '+=', 1: '-='}
format['operation'] = operator_dict[params[1]]
format['operand'] = params[2]
format['const_or_var'] = params[3]
return format
@staticmethod
def template(format):
project = Kernel.GlobalObjects.get_value("PROJECT")
template = '%s: ' % Format.blue('Change EXP')
if format['party_target'] == 0: # Entire Party
template += '%s ' % Format.bold('Entire Party')
else: # Specific Actor
actors = project.getData('Actors')
format['actor_name'] = actors[format['party_target']].name
template += '[%s: %s] ' % (Format.bold('%(party_target)04d'), Format.red('%(actor_name)s'))
template += '%s ' % Format.bold('%(operation)s')
if format['operand'] == 0: # Constant
template += '%s' % Format.blue('%(const_or_var)s')
else: # Variable
system = project.getData('System')
format['var_name'] = system.variables[format['const_or_var']]
template += 'Variable [%s: %s]' % (Format.bold('%(const_or_var)04d'), Format.blue('%(var_name)s'))
return template % format
class Command316(object):
"""Change Level"""
@staticmethod
def format(params):
format = {}
format['party_target'] = params[0]
operator_dict = {0: '+=', 1: '-='}
format['operation'] = operator_dict[params[1]]
format['operand'] = params[2]
format['const_or_var'] = params[3]
return format
@staticmethod
def template(format):
project = Kernel.GlobalObjects.get_value("PROJECT")
template = '%s: ' % Format.blue('Change Level')
if format['party_target'] == 0: # Entire Party
template += '%s ' % Format.bold('Entire Party')
else: # Specific Actor
actors = project.getData('Actors')
format['actor_name'] = actors[format['party_target']].name
template += '[%s: %s] ' % (Format.bold('%(party_target)04d'), Format.red('%(actor_name)s'))
template += '%s ' % Format.bold('%(operation)s')
if format['operand'] == 0: # Constant
template += '%s' % Format.blue('%(const_or_var)s')
else: # Variable
system = project.getData('System')
format['var_name'] = system.variables[format['const_or_var']]
template += 'Variable [%s: %s]' % (Format.bold('%(const_or_var)04d'), Format.blue('%(var_name)s'))
return template % format
class Command317(object):
"""Change Parameters"""
@staticmethod
def format(params):
format = {}
format['actor_id'] = params[0]
stat_dict = {0: 'maxHP', 1: 'maxSP', 2: 'str', 3: 'dex', 4: 'agi', 5: 'int'}
format['stat'] = stat_dict[params[1]]
operator_dict = {0: '+=', 1: '-='}
format['operation'] = operator_dict[params[2]]
format['operand'] = params[3]
format['const_or_var'] = params[4]
return format
@staticmethod
def template(format):
project = Kernel.GlobalObjects.get_value("PROJECT")
actors = project.getData('Actors')
format['actor_name'] = actors[format['actor_id']].name
template = '%s: [%s: %s].%s %s ' % (Format.blue('Change Parameters'), Format.bold('%(actor_id)04d'),
Format.red('%(actor_name)s'), Format.bold('%(stat)s'),
Format.bold('%(operation)s'))
if format['operand'] == 0: # Constant
template += '%s' % Format.blue('%(const_or_var)s')
else: # Variable
system = project.getData('System')
format['var_name'] = system.variables[format['const_or_var']]
template += 'Variable [%s: %s]' % (Format.bold('%(const_or_var)04d'), Format.blue('%(var_name)s'))
return template % format
class Command318(object):
"""Change Skills"""
@staticmethod
def format(params):
format = {}
format['actor_id'] = params[0]
skill_dict = {0: '.learn', 1: '.forget'}
format['operation'] = skill_dict[params[1]]
format['skill_id'] = params[2]
return format
@staticmethod
def template(format):
project = Kernel.GlobalObjects.get_value("PROJECT")
actors = project.getData('Actors')
skills = project.getData('Skills')
format['actor_name'] = actors[format['actor_id']].name
format['skill_name'] = skills[format['skill_id']].name
template = '%s: [%s: %s]%s [%s: %s]' % (Format.blue('Change Skills'), Format.red('%(actor_id)04d'),
Format.green('%(actor_name)s'), Format.bold('%(operation)s'),
Format.red('%(skill_id)04d'), Format.green('%(skill_name)s'))
return template % format
class Command319(object):
"""Change Equipment"""
@staticmethod
def format(params):
format = {}
format['actor_id'] = params[0]
equip_dict = {0: '.weapon', 1: '.shield', 2: '.helmet', 3: '.armor', 4: '.accessory'}
format['equip_type'] = params[1]
format['equip'] = equip_dict[params[1]]
format['equip_id'] = params[2]
return format
@staticmethod
def template(format):
project = Kernel.GlobalObjects.get_value("PROJECT")
actors = project.getData('Actors')
format['actor_name'] = actors[format['actor_id']].name
if format['equip_id'] == 0: # None
template = '%s: [%s: %s]%s = None' % (Format.blue('Change Equipment'), Format.red('%(actor_id)04d'),
Format.green('%(actor_name)s'), Format.bold('%(equip)s'))
else: # Valid Equip ID
if format['equip_type'] == 0: # Weapon
weapons = project.getData('Weapons')
format['equip_name'] = weapons[format['equip_id']].name
else: # Armor
armors = project.getData('Armors')
format['equip_name'] = armors[format['equip_id']].name
template = '%s: [%s: %s]%s = [%s: %s]' % (Format.blue('Change Equipment'), Format.red('%(actor_id)04d'),
Format.green('%(actor_name)s'), Format.bold('%(equip)s'),
Format.red('%(equip_id)04d'), Format.green('%(equip_name)s'))
return template % format
class Command320(object):
"""Change Actor Name"""
@staticmethod
def format(params):
format = {}
project = Kernel.GlobalObjects.get_value("PROJECT")
actors = project.getData('Actors')
format['actor_id'] = params[0]
format['actor_name'] = actors[format['actor_id']].name
format['new_name'] = params[1]
return format
@staticmethod
def template(format):
template = '%s: [%s: %s].name(\'%s\')' % (Format.blue('Change Actor Name'), Format.red('%(actor_id)04d'),
Format.green('%(actor_name)s'), Format.italic(Format.green('%(new_name)s')))
return template % format
class Command321(object):
"""Change Actor Class"""
@staticmethod
def format(params):
format = {}
project = Kernel.GlobalObjects.get_value("PROJECT")
actors = project.getData('Actors')
classes = project.getData('Classes')
format['actor_id'] = params[0]
format['actor_name'] = actors[format['actor_id']].name
format['class_id'] = params[1]
format['class_name'] = classes[params[1]].name
return format
@staticmethod
def template(format):
template = '%s: [%s: %s].class = [%s: %s]' % (Format.blue('Change Actor Class'), Format.red('%(actor_id)04d'),
Format.green('%(actor_name)s'), Format.red('%(class_id)04d'),
Format.green('%(class_name)s'))
return template % format
class Command322(object):
"""Change Actor Graphic"""
@staticmethod
def format(params):
format = {}
project = Kernel.GlobalObjects.get_value("PROJECT")
actors = project.getData('Actors')
format['actor_id'] = params[0]
format['actor_name'] = actors[format['actor_id']].name
format['character_graphic'] = params[1]
format['character_hue'] = params[2]
format['battler_graphic'] = params[3]
format['battler_hue'] = params[4]
return format
@staticmethod
def template(format):
template = '%s: [%s: %s] => Character[\'%s\', Hue = %s], Battler[\'%s\', Hue = %s]' % (Format.blue('Change Actor Graphic'),
Format.red('%(actor_id)04d'), Format.green('%(actor_name)s'),
Format.italic(Format.blue('%(character_graphic)s')), Format.bold('%(character_hue)03d'),
Format.italic(Format.blue('%(battler_graphic)s')), Format.bold('%(battler_hue)03d'))
return template % format
class Command331(object):
"""Change Enemy HP"""
@staticmethod
def format(params):
format = {}
if(params[0] & 0x80000000):
format['troop_target'] = -0x100000000 + params[0]
else:
format['troop_target'] = params[0] + 1
operator_dict = {0: '+=', 1: '-='}
format['operation'] = operator_dict[params[1]]
format['operand'] = params[2]
format['const_or_var'] = params[3]
format['allow_ko'] = params[4]
return format
@staticmethod
def template(format):
project = Kernel.GlobalObjects.get_value("PROJECT")
template = '%s: ' % Format.blue('Change Enemy HP')
if format['troop_target'] == -1: # Entire Troop
template += '%s ' % Format.bold('Entire Troop')
else: # Specific Enemy
template += '%s [%s] ' % (Format.bold('Enemy'), Format.red('%(troop_target)s'))
template += '%s ' % Format.bold('%(operation)s')
if format['operand'] == 0: # Constant
template += '%s' % Format.blue('%(const_or_var)s')
else: # Variable
system = project.getData('System')
format['var_name'] = system.variables[format['const_or_var']]
template += 'Variable [%s: %s]' % (Format.bold('%(const_or_var)04d'), Format.blue('%(var_name)s'))
if format['allow_ko'] == 1: # Can KO
template += ', %s' % (Format.bold('Allow KO'))
return template % format
class Command332(object):
"""Change Enemy SP"""
@staticmethod
def format(params):
format = {}
if(params[0] & 0x80000000):
format['troop_target'] = -0x100000000 + params[0]
else:
format['troop_target'] = params[0] + 1
operator_dict = {0: '+=', 1: '-='}
format['operation'] = operator_dict[params[1]]
format['operand'] = params[2]
format['const_or_var'] = params[3]
return format
@staticmethod
def template(format):
project = Kernel.GlobalObjects.get_value("PROJECT")
template = '%s: ' % Format.blue('Change Enemy SP')
if format['troop_target'] == -1: # Entire Troop
template += '%s ' % Format.bold('Entire Troop')
else: # Specific Enemy
template += '%s [%s] ' % (Format.bold('Enemy'), Format.red('%(troop_target)s'))
template += '%s ' % Format.bold('%(operation)s')
if format['operand'] == 0: # Constant
template += '%s' % Format.blue('%(const_or_var)s')
else: # Variable
system = project.getData('System')
format['var_name'] = system.variables[format['const_or_var']]
template += 'Variable [%s: %s]' % (Format.bold('%(const_or_var)04d'), Format.blue('%(var_name)s'))
return template % format
class Command333(object):
"""Change Enemy State"""
@staticmethod
def format(params):
format = {}
if(params[0] & 0x80000000):
format['troop_target'] = -0x100000000 + params[0]
else:
format['troop_target'] = params[0] + 1
operator_dict = {0: '+', 1: '-'}
format['operation'] = operator_dict[params[1]]
project = Kernel.GlobalObjects.get_value("PROJECT")
states = project.getData('States')
format['state_id'] = params[2]
format['state_name'] = states[format['state_id']].name
return format
@staticmethod
def template(format):
project = Kernel.GlobalObjects.get_value("PROJECT")
template = '%s: ' % Format.blue('Change Enemy State')
if format['troop_target'] == -1: # Entire Troop
template += '%s ' % Format.bold('Entire Troop')
else: # Specific Enemy
template += '%s [%s] ' % (Format.bold('Enemy'), Format.red('%(troop_target)s'))
template += '%s [%s: %s]' % (Format.bold('%(operation)s'), Format.bold('%(state_id)04d'), Format.green('%(state_name)s'))
return template % format
class Command334(object):
"""Enemy Recover All"""
@staticmethod
def format(params):
format = {}
if(params[0] & 0x80000000):
format['enemy_id'] = -0x100000000 + params[0]
else:
format['enemy_id'] = params[0] + 1
return format
@staticmethod
def template(format):
if format['enemy_id'] <= -1:
enemy = 'Entire Troop'
else:
enemy = '%s [%s] ' % (Format.bold('Enemy'), Format.red('%(enemy_id)s'))
template = '%s %s' % (
Format.color('#3BB9FF', 'Enemy Recover All:'),
enemy
)
return template % format
class Command335(object):
"""Enemy Appearance"""
@staticmethod
def format(params):
format = {}
format['enemy_pos'] = params[0] + 1
return format
@staticmethod
def template(format):
template = '%s: Enemy [%s]' % (Format.red('Enemy Appearance'), Format.green('%(enemy_pos)s'))
return template % format
class Command336(object):
"""Enemy Transform"""
@staticmethod
def format(params):
format = {}
project = Kernel.GlobalObjects.get_value("PROJECT")
enemies = project.getData('Enemies')
format['enemy_pos'] = params[0] + 1
format['enemy_id'] = params[1]
format['enemy_name'] = enemies[params[1]].name
return format
@staticmethod
def template(format):
template = '%s: Enemy [%s] => [%s: %s]' % (Format.red('Enemy Transform'), Format.green('%(enemy_pos)s'),
Format.red('%(enemy_id)04d'), Format.green('%(enemy_name)s'))
return template % format
class Command337(object):
"""Show Battle Animation"""
@staticmethod
def format(params):
format = {}
project = Kernel.GlobalObjects.get_value("PROJECT")
animations = project.getData('Animations')
format['target'] = params[0]
if(params[1] & 0x80000000):
format['target_id'] = -0x100000000 + params[1]
else:
format['target_id'] = params[1] + 1
format['anim_id'] = params[2]
format['anim_name'] = animations[params[2]].name
return format
@staticmethod
def template(format):
template = '%s: ' % Format.blue('Show Battle Animation')
if format['target'] == 0:
if format['target_id'] == -1:
template += '%s ' % Format.bold('Entire Troop')
else:
template += 'Enemy [%s] ' % Format.green('%(target_id)s')
else:
if format['target_id'] == -1:
template += '%s ' % Format.bold('Entire Party')
else:
template += 'Party Actor [%s] ' % Format.green('%(target_id)s')
template += ', [%s: %s]' % (Format.red('%(anim_id)04d'), Format.green('%(anim_name)s'))
return template % format
class Command338(object):
"""Deal Damage"""
@staticmethod
def format(params):
format = {}
format['target'] = params[0]
if(params[1] & 0x80000000):
format['target_id'] = -0x100000000 + params[1]
else:
format['target_id'] = params[1] + 1
format['operand'] = params[2]
format['const_or_var'] = params[3]
return format
@staticmethod
def template(format):
template = '%s: ' % Format.blue('Deal Damage')
if format['target'] == 0:
if format['target_id'] == -1:
template += '%s ' % Format.bold('Entire Troop')
else:
template += 'Enemy [%s] ' % Format.green('%(target_id)s')
else:
if format['target_id'] == -1:
template += '%s ' % Format.bold('Entire Party')
else:
template += 'Party Actor [%s] ' % Format.green('%(target_id)s')
if format['operand'] == 0:
template += ', %s' % Format.red('%(const_or_var)s')
else:
project = Kernel.GlobalObjects.get_value("PROJECT")
system = project.getData('System')
format['var_name'] = system.variables[format['const_or_var']]
template += ', Variable [%s: %s]' % (Format.green('%(const_or_var)04d'), Format.red('%(var_name)s'))
return template % format
class Command339(object):
"""Force Action"""
@staticmethod
def format(params):
format = {}
format['battler'] = params[0]
format['battler_id'] = params[1] + 1
format['action'] = params[2]
format['action_id'] = params[3]
if(params[4] & 0x80000000):
format['action_target'] = -0x100000000 + params[4]
else:
format['action_target'] = params[4] + 1
timing_dict = {0: 'Normally', 1: 'Now'}
format['timing'] = timing_dict[params[5]]
return format
@staticmethod
def template(format):
template = '%s: ' % Format.blue('Force Action')
if format['battler'] == 0:
template += 'Enemy [%s]' % Format.green('%(battler_id)s')
else:
template += 'Party Actor [%s]' % Format.green('%(battler_id)s')
if format['action'] == 0:
action_dict = {0: 'Attack', 1: 'Defend', 2: 'Escape', 3: 'Do Nothing'}
format['action_name'] = action_dict[format['action_id']]
template += ', %s ' % Format.bold('%(action_name)s')
else:
project = Kernel.GlobalObjects.get_value("PROJECT")
skills = project.getData('Skills')
format['skill_name'] = skills[format['action_id']].name
template += ', Skill [%s: %s] ' % (Format.red('%(action_id)04d'), Format.green('%(skill_name)s'))
if format['action_target'] < 0:
target_dict = {-2: 'Last Target', -1: 'Random'}
format['target'] = target_dict[format['action_target']]
template += '=> %s, ' % Format.bold('%(target)s')
else:
template += '=> Target ID [%s], ' % Format.green('%(action_target)s')
template += 'Execute %s' % Format.bold('%(timing)s')
return template % format
class Command340(object):
"""Abort Battle"""
@staticmethod
def format(params):
format = {}
return format
@staticmethod
def template(format):
return '%s' % (Format.bold('Abort Battle'))
class Command351(object):
"""Call Menu Screen"""
@staticmethod
def format(params):
format = {}
return format
@staticmethod
def template(format):
return '%s' % (Format.bold('Call Menu Screen'))
class Command352(object):
"""Call Save Screen"""
@staticmethod
def format(params):
format = {}
format['params'] = params
return format
@staticmethod
def template(format):
return Format.color('#2C3539', 'Call Save Screen')
class Command353(object):
"""Game Over"""
@staticmethod
def format(params):
format = {}
return format
@staticmethod
def template(format):
return '%s' % (Format.bold(Format.color('#2C3539', 'Game Over')))
class Command354(object):
"""Return to Title Screen"""
@staticmethod
def format(params):
format = {}
return format
@staticmethod
def template(format):
return '%s' % (Format.bold('Return to Title Screen'))
class Command355(object):
"""Script"""
@staticmethod
def format(params):
format = {}
format['text'] = Kernel.escapeHTML(params[0])
return format
@staticmethod
def template(format):
template = '%s: %s' % (Format.bold('Script'), '%(text)s')
return template % format
class Command655(object):
"""Script Extra Lines"""
@staticmethod
def format(params):
format = {}
format['text'] = Kernel.escapeHTML(params[0])
return format
@staticmethod
def template(format):
template = '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;%s %s' % (':', '%(text)s')
return template % format
class Command412(object):
"""Conditional Branch End"""
@staticmethod
def format(params):
format = {}
return format
@staticmethod
def template(format):
return Format.blue('Branch End')
class Command404(object):
"""Show Choices Branch End"""
@staticmethod
def format(params):
format = {}
return format
@staticmethod
def template(format):
return Format.blue('Choices End')
'''
Created on Sep 9, 2010
a Python implementation of the RGSS1 RPG module
Classes in this module
----------------------
Actor
Animation
Armor
AudioFile
Class
CommonEvent
Enemy
Event
EventCommand
Item
Map
MapInfo
MoveCommand
MoveRoute
Skill
State
System
Tileset
Troop
Weapon
'''
import types
from PyitectConsumes import Table, Color, Tone
class _Actor(object):
_arc_class_path = "RPG::Actor"
_arc_instance_variables = ['id', 'name', 'class_id', 'initial_level',
'final_level', 'exp_basis', 'exp_inflation',
'exp_list', 'character_name', 'character_hue',
'battler_name', 'battler_hue', 'parameters',
'weapon_id', 'armor1_id', 'armor2_id',
'armor3_id', 'armor4_id', 'armor1_fix',
'armor2_fix', 'armor3_fix', 'armor4_fix', 'note']
def __init__(self):
self.id = 0
self.name = ""
self.class_id = 1
self.initial_level = 1
self.final_level = 99
self.exp_basis = 30
self.exp_inflation = 30
self.exp_list = []
self.character_name = ""
self.character_hue = 0
self.battler_name = ""
self.battler_hue = 0
self.parameters = Table(6, 100)
for i in range(1, 100):
self.parameters[0, i] = 500 + i * 50
self.parameters[1, i] = 500 + i * 50
self.parameters[2, i] = 50 + i * 5
self.parameters[3, i] = 50 + i * 5
self.parameters[4, i] = 50 + i * 5
self.parameters[5, i] = 50 + i * 5
self.weapon_id = 0
self.armor1_id = 0
self.armor2_id = 0
self.armor3_id = 0
self.armor4_id = 0
self.weapon_fix = False
self.armor1_fix = False
self.armor2_fix = False
self.armor3_fix = False
self.armor4_fix = False
self.note = ''
class _Animation(object):
_arc_class_path = "RPG::Animation"
_arc_instance_variables = ['id', 'name', 'animation_name',
'animation_hue', 'position', 'frame_max',
'frames', 'timings']
def __init__(self):
self.id = 0
self.name = ""
self.animation_name = ""
self.animation_hue = 0
self.position = 1
self.frame_max = 1
self.frames = [RPG.Animation.Frame()]
self.timings = []
class _Frame(object):
_arc_class_path = "RPG::Animation::Frame"
_arc_instance_variables = ['cell_max', 'cell_data']
def __init__(self):
self.cell_max = 0
self.cell_data = Table(0, 0)
class _Timing(object):
_arc_class_path = "RPG::Animation::Timing"
_arc_instance_variables = ['frame', 'se', 'flash_scope',
'flash_color', 'flash_duration',
'condition']
def __init__(self):
self.frame = 0
self.se = RPG.AudioFile("", 80)
self.flash_scope = 0
self.flash_color = Color(255, 255, 255, 255)
self.flash_duration = 5
self.condition = 0
class _Armor(object):
_arc_class_path = "RPG::Armor"
_arc_instance_variables = ['id', 'name', 'icon_name', 'description',
'kind', 'auto_state_id', 'price', 'pdef',
'mdef', 'eva', 'str_plus', 'dex_plus',
'agi_plus', 'int_plus', 'guard_element_set',
'guard_state_set', 'note']
def __init__(self):
self.id = 0
self.name = ""
self.icon_name = ""
self.description = ""
self.kind = 0
self.auto_state_id = 0
self.price = 0
self.pdef = 0
self.mdef = 0
self.eva = 0
self.str_plus = 0
self.dex_plus = 0
self.agi_plus = 0
self.int_plus = 0
self.guard_element_set = []
self.guard_state_set = []
self.note = ''
class _AudioFile(object):
_arc_class_path = "RPG::AudioFile"
_arc_instance_variables = ['name', 'volume', 'pitch']
def __init__(self, name="", volume=100, pitch=100):
self.name = name
self.volume = volume
self.pitch = pitch
class _Class(object):
_arc_class_path = "RPG::Class"
_arc_instance_variables = ['id', 'name', 'position', 'weapon_set',
'armor_set', 'element_ranks', 'state_ranks',
'learnings', 'note']
def __init__(self):
self.id = 0
self.name = ""
self.position = 0
self.weapon_set = []
self.armor_set = []
self.element_ranks = Table(1)
self.state_ranks = Table(1)
self.learnings = []
self.note = ''
class _Learning(object):
_arc_class_path = "RPG::Class::Learning"
_arc_instance_variables = ['level', 'skill_id']
def __init__(self):
self.level = 1
self.skill_id = 1
class _CommonEvent(object):
_arc_class_path = "RPG::CommonEvent"
_arc_instance_variables = ['id', 'name', 'trigger', 'switch_id', 'list']
def __init__(self):
self.id = 0
self.name = ""
self.trigger = 0
self.switch_id = 1
self.list = [RPG.EventCommand()]
self._common = True
class _Enemy(object):
_arc_class_path = "RPG::Enemy"
_arc_instance_variables = ['id', 'name', 'battler_name', 'battler_hue',
'maxhp', 'maxsp', 'str', 'dex', 'agi', 'int',
'atk', 'pdef', 'mdef', 'eva', 'animation1_id',
'animation2_id', 'element_ranks',
'state_ranks', 'actions', 'exp', 'gold',
'item_id', 'weapon_id', 'armor_id',
'treasure_prob', 'note']
def __init__(self):
self.id = 0
self.name = ""
self.battler_name = ""
self.battler_hue = 0
self.maxhp = 500
self.maxsp = 500
self.str = 50
self.dex = 50
self.agi = 50
self.int = 50
self.atk = 100
self.pdef = 100
self.mdef = 100
self.eva = 0
self.animation1_id = 0
self.animation2_id = 0
self.element_ranks = Table(1)
self.state_ranks = Table(1)
self.actions = [RPG.Enemy.Action()]
self.exp = 0
self.gold = 0
self.item_id = 0
self.weapon_id = 0
self.armor_id = 0
self.treasure_prob = 100
self.note = ''
class _Action(object):
_arc_class_path = "RPG::Enemy::Action"
_arc_instance_variables = ['kind', 'basic', 'skill_id',
'condition_turn_a', 'condition_turn_b',
'condition_hp', 'condition_level',
'condition_switch_id', 'rating']
def __init__(self):
self.kind = 0
self.basic = 0
self.skill_id = 1
self.condition_turn_a = 0
self.condition_turn_b = 1
self.condition_hp = 100
self.condition_level = 1
self.condition_switch_id = 0
self.rating = 5
class _Event(object):
_arc_class_path = "RPG::Event"
_arc_instance_variables = ['id', 'name', 'x', 'y', 'pages']
def __init__(self, x=0, y=0):
self.id = 0
self.name = ""
self.x = x
self.y = y
self.pages = [RPG.Event.Page()]
self._common = False
class _EventPage(object):
_arc_class_path = "RPG::Event::Page"
_arc_instance_variables = ['condition', 'graphic', 'move_type',
'move_speed', 'move_frequency',
'move_route', 'walk_anime', 'step_anime',
'direction_fix', 'through',
'always_on_top', 'trigger', 'list']
def __init__(self):
self.condition = RPG.Event.Page.Condition()
self.graphic = RPG.Event.Page.Graphic()
self.move_type = 0
self.move_speed = 3
self.move_frequency = 3
self.move_route = RPG.MoveRoute()
self.walk_anime = True
self.step_anime = False
self.direction_fix = False
self.through = False
self.always_on_top = False
self.trigger = 0
self.list = [RPG.EventCommand()]
class _EventCondition(object):
_arc_class_path = "RPG::Event::Page::Condition"
_arc_instance_variables = ['switch1_valid', 'switch2_valid',
'variable_valid', 'self_switch_valid',
'switch1_id', 'switch2_id',
'variable_id', 'variable_value',
'self_switch_ch']
def __init__(self):
self.switch1_valid = False
self.switch2_valid = False
self.variable_valid = False
self.self_switch_valid = False
self.switch1_id = 1
self.switch2_id = 1
self.variable_id = 1
self.variable_value = 0
self.self_switch_ch = "A"
class _EventGraphic(object):
_arc_class_path = "RPG::Event::Page::Graphic"
_arc_instance_variables = ['tile_id', 'character_name',
'character_hue', 'direction',
'pattern', 'opacity', 'blend_type']
def __init__(self):
self.tile_id = 0
self.character_name = ""
self.character_hue = 0
self.direction = 2
self.pattern = 0
self.opacity = 255
self.blend_type = 0
class _EventCommand(object):
_arc_class_path = "RPG::EventCommand"
_arc_instance_variables = ['code', 'indent', 'parameters']
def __init__(self, code=0, indent=0, parameters=[]):
self.code = code
self.indent = indent
self.parameters = parameters
class _Item(object):
_arc_class_path = "RPG::Item"
_arc_instance_variables = ['id', 'name', 'icon_name', 'description',
'scope', 'occasion', 'animation1_id',
'animation2_id', 'menu_se', 'common_event_id',
'price', 'consumable', 'parameter_type',
'parameter_points', 'recover_hp_rate',
'recover_hp', 'recover_sp_rate', 'recover_sp',
'hit', 'pdef_f', 'mdef_f', 'variance',
'element_set', 'plus_state_set',
'minus_state_set', 'note']
def __init__(self):
self.id = 0
self.name = ""
self.icon_name = ""
self.description = ""
self.scope = 0
self.occasion = 0
self.animation1_id = 0
self.animation2_id = 0
self.menu_se = RPG.AudioFile("", 80)
self.common_event_id = 0
self.price = 0
self.consumable = True
self.parameter_type = 0
self.parameter_points = 0
self.recover_hp_rate = 0
self.recover_hp = 0
self.recover_sp_rate = 0
self.recover_sp = 0
self.hit = 100
self.pdef_f = 0
self.mdef_f = 0
self.variance = 0
self.element_set = []
self.plus_state_set = []
self.minus_state_set = []
self.note = ''
class _Map(object):
_arc_class_path = "RPG::Map"
_arc_instance_variables = ['tileset_id', 'width', 'height',
'autoplay_bgm', 'bgs', 'encounter_list',
'encounter_step', 'data', 'events']
def __init__(self, width=20, height=15):
self.tileset_id = 1
self.width = width
self.height = height
self.autoplay_bgm = False
self.bgm = RPG.AudioFile()
self.autoplay_bgs = False
self.bgs = RPG.AudioFile("", 80)
self.encounter_list = []
self.encounter_step = 30
self.data = Table(width, height, 3)
self.events = {}
class _MapInfo(object):
_arc_class_path = "RPG::MapInfo"
_arc_instance_variables = ['name', 'parent_id', 'order', 'expanded',
'scroll_x', 'scroll_y']
def __init__(self):
self.name = ""
self.parent_id = 0
self.order = 0
self.expanded = False
self.scroll_x = 0
self.scroll_y = 0
class _MoveCommand(object):
_arc_class_path = "RPG::MoveCommand"
_arc_instance_variables = ['code', 'parameters']
def __init__(self, code=0, parameters=[]):
self.code = code
self.parameters = parameters
class _MoveRoute(object):
_arc_class_path = "RPG::MoveRoute"
_arc_instance_variables = ['repeat', 'skippable', 'list']
def __init__(self):
self.repeat = True
self.skippable = False
self.list = [RPG.MoveCommand()]
class _Skill(object):
_arc_class_path = "RPG::Skill"
_arc_instance_variables = ['id', 'name', 'icon_name', 'description',
'scope', 'occasion', 'animation1_id',
'animation2_id', 'menu_se', 'common_event_id',
'sp_cost', 'power', 'atk_f', 'eva_f', 'str_f',
'dex_f', 'agi_f', 'int_f', 'hit', 'pdef_f',
'mdef_f', 'variance', 'element_set',
'plus_state_set', 'minus_state_set', 'note']
def __init__(self):
self.id = 0
self.name = ""
self.icon_name = ""
self.description = ""
self.scope = 0
self.occasion = 1
self.animation1_id = 0
self.animation2_id = 0
self.menu_se = RPG.AudioFile("", 80)
self.common_event_id = 0
self.sp_cost = 0
self.power = 0
self.atk_f = 0
self.eva_f = 0
self.str_f = 0
self.dex_f = 0
self.agi_f = 0
self.int_f = 100
self.hit = 100
self.pdef_f = 0
self.mdef_f = 100
self.variance = 15
self.element_set = []
self.plus_state_set = []
self.minus_state_set = []
self.note = ''
class _State(object):
_arc_class_path = "RPG::State"
_arc_instance_variables = ['id', 'name', 'animation_id', 'restriction',
'nonresistance', 'zero_hp', 'cant_get_exp',
'cant_evade', 'slip_damage', 'rating',
'hit_rate', 'maxhp_rate', 'maxsp_rate',
'str_rate', 'dex_rate', 'int_rate',
'atk_rate', 'pdef_rate', 'mdef_rate', 'eva',
'battle_only', 'hold_turn',
'auto_release_prob', 'shock_release_prob',
'guard_element_set', 'plus_state_set',
'minus_state_set', 'note']
def __init__(self):
self.id = 0
self.name = ""
self.animation_id = 0
self.restriction = 0
self.nonresistance = False
self.zero_hp = False
self.cant_get_exp = False
self.cant_evade = False
self.slip_damage = False
self.rating = 5
self.hit_rate = 100
self.maxhp_rate = 100
self.maxsp_rate = 100
self.str_rate = 100
self.dex_rate = 100
self.agi_rate = 100
self.int_rate = 100
self.atk_rate = 100
self.pdef_rate = 100
self.mdef_rate = 100
self.eva = 0
self.battle_only = True
self.hold_turn = 0
self.auto_release_prob = 0
self.shock_release_prob = 0
self.guard_element_set = []
self.plus_state_set = []
self.minus_state_set = []
self.note = ''
class _System(object):
_arc_class_path = "RPG::System"
_arc_instance_variables = ['magic_number', 'party_members', 'elements',
'switches', 'variables', 'windowskin_name',
'title_name', 'gameover_name',
'battle_transition', 'title_bgm',
'battle_bgm', 'battle_end_me', 'gameover_me',
'cursor_se', 'decision_se', 'cancel_se',
'buzzer_se', 'equip_se', 'shop_se', 'save_se',
'load_se', 'battle_start_se', 'escape_se',
'actor_collapse_se', 'words', 'test_battlers',
'test_troop_id', 'start_map_id', 'start_x',
'start_y', 'battleback_name', 'battler_name',
'battler_hue', 'edit_map_id']
def __init__(self):
self.magic_number = 0
self.party_members = [1]
self.elements = [None, ""]
self.switches = [None, ""]
self.variables = [None, ""]
self.windowskin_name = ""
self.title_name = ""
self.gameover_name = ""
self.battle_transition = ""
self.title_bgm = RPG.AudioFile()
self.battle_bgm = RPG.AudioFile()
self.battle_end_me = RPG.AudioFile()
self.gameover_me = RPG.AudioFile()
self.cursor_se = RPG.AudioFile("", 80)
self.decision_se = RPG.AudioFile("", 80)
self.cancel_se = RPG.AudioFile("", 80)
self.buzzer_se = RPG.AudioFile("", 80)
self.equip_se = RPG.AudioFile("", 80)
self.shop_se = RPG.AudioFile("", 80)
self.save_se = RPG.AudioFile("", 80)
self.load_se = RPG.AudioFile("", 80)
self.battle_start_se = RPG.AudioFile("", 80)
self.escape_se = RPG.AudioFile("", 80)
self.actor_collapse_se = RPG.AudioFile("", 80)
self.enemy_collapse_se = RPG.AudioFile("", 80)
self.words = RPG.System.Words()
self.test_battlers = []
self.test_troop_id = 1
self.start_map_id = 1
self.start_x = 0
self.start_y = 0
self.battleback_name = ""
self.battler_name = ""
self.battler_hue = 0
self.edit_map_id = 1
class _TestBattler(object):
_arc_class_path = "RPG::System::TestBattler"
_arc_instance_variables = ['actor_id', 'level', 'weapon_id',
'armor1_id', 'armor2_id', 'armor3_id',
'armor4_id']
def __init__(self):
self.actor_id = 1
self.level = 1
self.weapon_id = 0
self.armor1_id = 0
self.armor2_id = 0
self.armor3_id = 0
self.armor4_id = 0
class _Words(object):
_arc_class_path = "RPG::Words"
_arc_instance_variables = ['gold', 'hp', 'sp', 'str', 'dex', 'agi',
'int', 'atk', 'pdef', 'mdef', 'weapon',
'armor1', 'armor2', 'armor3', 'armor4',
'attack', 'skill', 'guard', 'item', 'equip']
def __init__(self):
self.gold = ""
self.hp = ""
self.sp = ""
self.str = ""
self.dex = ""
self.agi = ""
self.int = ""
self.atk = ""
self.pdef = ""
self.mdef = ""
self.weapon = ""
self.armor1 = ""
self.armor2 = ""
self.armor3 = ""
self.armor4 = ""
self.attack = ""
self.skill = ""
self.guard = ""
self.item = ""
self.equip = ""
class _Tileset(object):
_arc_class_path = "RPG::Tileset"
_arc_instance_variables = ['id', 'name', 'tileset_name',
'autotile_names', 'panorama_name',
'panorama_hue', 'fog_name', 'fog_hue',
'fog_opacity', 'fog_blend_type', 'fog_zoom',
'fog_sx', 'fog_sy', 'battleback_name',
'passages', 'priorities', 'terrain_tags']
def __init__(self):
self.id = 0
self.name = ""
self.tileset_name = ""
self.autotile_names = [""] * 7
self.panorama_name = ""
self.panorama_hue = 0
self.fog_name = ""
self.fog_hue = 0
self.fog_opacity = 64
self.fog_blend_type = 0
self.fog_zoom = 200
self.fog_sx = 0
self.fog_sy = 0
self.battleback_name = ""
self.passages = Table(384)
self.priorities = Table(384)
self.priorities[0] = 5
self.terrain_tags = Table(384)
class _Troop(object):
_arc_class_path = "RPG::Troop"
_arc_instance_variables = ['id', 'name', 'members', 'pages', 'note']
def __init__(self):
self.id = 0
self.name = ""
self.members = []
self.pages = [RPG.Troop.Page()]
self.note = ''
class _TroopPage(object):
_arc_class_path = "RPG::Troop::Page"
_arc_instance_variables = ['span', 'list']
def __init__(self):
self.condition = RPG.Troop.Page.Condition()
self.span = 0
self.list = [RPG.EventCommand()]
class _TroopCondition(object):
_arc_class_path = "RPG::Troop::Page::Condition"
_arc_instance_variables = ['turn_valid', 'enemy_valid',
'actor_valid', 'switch_valid',
'turn_a', 'turn_b', 'enemy_index',
'enemy_hp', 'actor_id', 'actor_hp',
'switch_id']
def __init__(self):
self.turn_valid = False
self.enemy_valid = False
self.actor_valid = False
self.switch_valid = False
self.turn_a = 0
self.turn_b = 0
self.enemy_index = 0
self.enemy_hp = 50
self.actor_id = 1
self.actor_hp = 50
self.switch_id = 1
class _Member(object):
_arc_class_path = "RPG::Troop::Member"
_arc_instance_variables = ['enemy_id', 'x', 'y', 'hidden', 'immortal']
def __init__(self):
self.enemy_id = 1
self.x = 0
self.y = 0
self.hidden = False
self.immortal = False
class _Weapon(object):
_arc_class_path = "RPG::Weapon"
_arc_instance_variables = ['id', 'name', 'icon_name', 'description',
'animation1_id', 'animation2_id', 'price',
'atk', 'pdef', 'mdef', 'str_plus', 'dex_plus',
'agi_plus', 'int_plus', 'element_set',
'plus_state_set', 'minus_state_set', 'note']
def __init__(self):
self.id = 0
self.name = ""
self.icon_name = ""
self.description = ""
self.animation1_id = 0
self.animation2_id = 0
self.price = 0
self.atk = 0
self.pdef = 0
self.mdef = 0
self.str_plus = 0
self.dex_plus = 0
self.agi_plus = 0
self.int_plus = 0
self.element_set = []
self.plus_state_set = []
self.minus_state_set = []
self.note = ''
def instance_repr(self):
results = []
for key, value in list(self.__dict__.items()):
if key[0] != "_":
if not isinstance(value, (types.FunctionType, type, types.MethodType,
types.ModuleType, slice, types.LambdaType,
types.GeneratorType)):
results.append(key)
parts = []
for key in results:
parts.append("%s:%s" % (key, repr(getattr(self, key))))
template = ("%s, " * (len(results) - 1)) + "%s"
data = tuple(parts)
instane_vars = template % data
return "<%s instance at %s: %s>" % (self.__class__.__name__, id(self), instane_vars)
class RPG(object):
__repr__ = instance_repr
_arc_class_path = "RPG"
Actor = _Actor
Animation = _Animation
Animation.Frame = _Frame
Animation.Timing = _Timing
Armor = _Armor
AudioFile = _AudioFile
Weapon = _Weapon
Troop = _Troop
Troop.Member = _Member
Troop.Page = _TroopPage
Troop.Page.Condition = _TroopCondition
Tileset = _Tileset
System = _System
System.TestBattler = _TestBattler
System.Words = _Words
State = _State
Skill = _Skill
MoveRoute = _MoveRoute
MoveCommand = _MoveCommand
MapInfo = _MapInfo
Map = _Map
Item = _Item
EventCommand = _EventCommand
Event = _Event
Event.Page = _EventPage
Event.Page.Graphic = _EventGraphic
Event.Page.Condition = _EventCondition
Enemy = _Enemy
Enemy.Action = _Action
CommonEvent = _CommonEvent
Class = _Class
Class.Learning = _Learning
Actor.__repr__ = instance_repr
Animation.__repr__ = instance_repr
Animation.Frame.__repr__ = instance_repr
Animation.Timing.__repr__ = instance_repr
Armor.__repr__ = instance_repr
AudioFile.__repr__ = instance_repr
Weapon.__repr__ = instance_repr
Troop.__repr__ = instance_repr
Troop.Member.__repr__ = instance_repr
Troop.Page.__repr__ = instance_repr
Troop.Page.Condition.__repr__ = instance_repr
Tileset.__repr__ = instance_repr
System.__repr__ = instance_repr
System.TestBattler.__repr__ = instance_repr
System.Words.__repr__ = instance_repr
State.__repr__ = instance_repr
Skill.__repr__ = instance_repr
MoveRoute.__repr__ = instance_repr
MoveCommand.__repr__ = instance_repr
MapInfo.__repr__ = instance_repr
Map.__repr__ = instance_repr
Item.__repr__ = instance_repr
EventCommand.__repr__ = instance_repr
Event.__repr__ = instance_repr
Event.Page.__repr__ = instance_repr
Event.Page.Graphic.__repr__ = instance_repr
Event.Page.Condition.__repr__ = instance_repr
Enemy.__repr__ = instance_repr
Enemy.Action.__repr__ = instance_repr
CommonEvent.__repr__ = instance_repr
Class.__repr__ = instance_repr
Class.Learning.__repr__ = instance_repr
def extend_namespace(namespace):
import sys
module = sys.modules[__name__]
namespace.update(module.__dict__)
"""
Created on Sep 9, 2010
contains classes and functions that are used through out the project
Classes in this module
-----------------------
Table - three dimensional table
Color - contains RGB color data
Tone - contains RGBGr tone data
"""
import numpy
from struct import pack, unpack
class Table(object):
"""a three dimensional table object"""
_arc_class_path = "Table"
def __init__(self, *args):
if len(args) != 1 and len(args) != 2 and len(args) != 3:
raise TypeError(
"wrong number of arguments (%d for 1, 2 or 3)" % len(args))
self.dim = len(args)
self.xsize = args[0]
if len(args) >= 2:
self.ysize = args[1]
else:
self.ysize = 1
if len(args) == 3:
self.zsize = args[2]
else:
self.zsize = 1
if self.dim == 3:
shape = (self.xsize, self.ysize, self.zsize)
elif self.dim == 2:
shape = (self.xsize, self.ysize)
else:
shape = (self.xsize,)
self._data = numpy.zeros(shape, dtype=numpy.int16)
self._data = numpy.reshape(self._data, shape, order='F')
def __getitem__(self, key):
if isinstance(key, int):
if self.dim > 1:
raise TypeError(
"wrong number of arguments (%d for %d)" % (1, self.dim))
elif len(key) != self.dim:
raise TypeError(
"wrong number of arguments (%d for %d)" % (len(key), self.dim))
return self._data[key]
def __setitem__(self, key, value):
if isinstance(key, int):
if self.dim > 1:
raise TypeError(
"wrong number of arguments (%d for %d)" % (1, self.dim))
elif len(key) != self.dim:
raise TypeError(
"wrong number of arguments (%d for %d)" % (len(key), self.dim))
try:
self._data[key] = value
except:
print('__SETITEM__ THREW EXCEPTION')
def resize(self, *args):
# should work to increase and decrease the table size
if len(args) != self.dim:
raise TypeError(
"wrong number of arguments (%d for %d)" % (len(args), self.dim))
self.xsize = args[0]
if len(args) >= 2:
self.ysize = args[1]
else:
self.ysize = 1
if len(args) == 3:
self.zsize = args[2]
else:
self.zsize = 1
newdata = numpy.zeros(self.getShape(), dtype=numpy.int16)
shape = self._data.shape
mask = [0, 0, 0]
if self.dim == 1:
if self.xsize >= shape[0]:
mask[0] = shape[0]
else:
mask[0] = self.xsize
newdata[:mask[0]] = self._data[:mask[0]]
elif self.dim == 2:
if self.xsize >= shape[0]:
mask[0] = shape[0]
else:
mask[0] = self.xsize
if self.ysize >= shape[1]:
mask[1] = shape[1]
else:
mask[1] = self.ysize
newdata[:mask[0], :mask[1]] = self._data[:mask[0], :mask[1]]
elif self.dim == 3:
if self.xsize >= shape[0]:
mask[0] = shape[0]
else:
mask[0] = self.xsize
if self.ysize >= shape[1]:
mask[1] = shape[1]
else:
mask[1] = self.ysize
if self.zsize >= shape[2]:
mask[2] = shape[2]
else:
mask[2] = self.zsize
newdata[:mask[0], :mask[1], :mask[2]] = self._data[
:mask[0], :mask[1], :mask[2]]
self._data = newdata
def _arc_dump(self, d=0):
s = pack("<IIII", self.dim, self.xsize, self.ysize, self.zsize)
data = self._data.flatten('F').tolist()
s += pack("<" + ("h" * (self.xsize * self.ysize * self.zsize)), *data)
return s
@staticmethod
def _arc_load(s):
dim, nx, ny, nz = unpack("<IIII", s[0:16])
size = nx * ny * nz
data = numpy.array(
unpack("<" + ("h" * size), s[16:16 + size * 2]), dtype=numpy.int16)
if dim == 3:
t = Table(nx, ny, nz)
shape = (nx, ny, nz)
elif dim == 2:
t = Table(nx, ny)
shape = (nx, ny)
elif dim == 1:
t = Table(nx)
shape = (nx,)
data = numpy.reshape(data, shape, order="F")
t._data = data
return t
def getShape(self):
if self.dim == 3:
shape = (self.xsize, self.ysize, self.zsize)
elif self.dim == 2:
shape = (self.xsize, self.ysize)
else:
shape = (self.xsize,)
return shape
class Color(object):
"""a bare bones color object"""
_arc_class_path = "Color"
def __init__(self, red, green, blue, alpha=255):
if red > 255:
red = 255
if red < 0:
red = 0
if green > 255:
green = 255
if green < 0:
green = 0
if blue > 255:
blue = 255
if blue < 0:
blue = 0
if alpha > 255:
alpha = 255
if alpha < 0:
alpha = 0
self.red = red
self.green = green
self.blue = blue
self.alpha = alpha
def set(self, red, green, blue, alpha=255):
if red > 255:
red = 255
if red < 0:
red = 0
if green > 255:
green = 255
if green < 0:
green = 0
if blue > 255:
blue = 255
if blue < 0:
blue = 0
if alpha > 255:
alpha = 255
if alpha < 0:
alpha = 0
self.red = red
self.green = green
self.blue = blue
self.alpha = alpha
def _arc_dump(self, d=0):
return pack("<ffff", self.red, self.green, self.blue, self.alpha)
@staticmethod
def _arc_load(s):
return Color(*unpack("<ffff", s))
class Tone(object):
"""a bare bones tone class"""
_arc_class_path = "Tone"
def __init__(self, red, green, blue, gray=0):
if red > 255:
red = 255
if red < -255:
red = -255
if green > 255:
green = 255
if green < -255:
green = -255
if blue > 255:
blue = 255
if blue < -255:
blue = -255
if gray > 255:
gray = 255
if gray < -255:
gray = -255
self.red = red
self.green = green
self.blue = blue
self.gray = gray
def set(self, red, green, blue, gray=0):
if red > 255:
red = 255
if red < -255:
red = -255
if green > 255:
green = 255
if green < -255:
green = -255
if blue > 255:
blue = 255
if blue < -255:
blue = -255
if gray > 255:
gray = 255
if gray < -255:
gray = -255
self.red = red
self.green = green
self.blue = blue
self.gray = gray
def _arc_dump(self, d=0):
return pack("<ffff", self.red, self.green, self.blue, self.gray)
@staticmethod
def _arc_load(s):
return Tone(*unpack("<ffff", s))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment