Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
841de15
add build-wc-flag-metadata, build-wc-objective-metadata
kielbasiago Nov 3, 2022
5c37f4f
update gitignore for new artifacts
kielbasiago Nov 3, 2022
f88c435
more cleanup
kielbasiago Nov 3, 2022
7c17a6a
remove metadata writer from wc.py
kielbasiago Nov 4, 2022
28e903b
add graphics/tools/print_sprite.py
kielbasiago Nov 10, 2022
6c2ce12
remove added whitespace
kielbasiago Nov 10, 2022
60a595a
print_sprite now takes ids
kielbasiago Nov 10, 2022
dad6ec4
allow for pose_id
kielbasiago Nov 11, 2022
28c92ad
append alpha colors
kielbasiago Nov 11, 2022
8f82cbc
parse pose id, default ot 1
kielbasiago Nov 11, 2022
8aebc1d
update sprite helper
kielbasiago Nov 17, 2022
d618487
add api/get_sprite_bytes
kielbasiago Nov 18, 2022
d21f072
add api/get_sprite_base64.py
kielbasiago Nov 19, 2022
a504c99
no longer write to file
kielbasiago Nov 19, 2022
e2d5c89
cleanup comment
kielbasiago Nov 19, 2022
22a5bcb
properly base64 image
kielbasiago Nov 19, 2022
417f4bf
return tuple from get_rgb_bytes
kielbasiago Nov 20, 2022
7a3d7be
add get_sprite_palette_bytes.py
kielbasiago Nov 20, 2022
f4e3813
fix pose 40
kielbasiago Nov 22, 2022
3155688
update pose 40
kielbasiago Nov 22, 2022
b9c7739
correct output of print_sprite
kielbasiago Nov 23, 2022
0c981e0
add get_sprites, add palette_bytes local fn
kielbasiago Nov 23, 2022
8d2f252
add locke-squall example
kielbasiago Nov 23, 2022
182167a
add squall palette?
kielbasiago Nov 23, 2022
fa1366e
remove locke-squall sprite
kielbasiago Nov 23, 2022
7c508d9
add latest hoxnorf sprites
kielbasiago Nov 23, 2022
6638bfd
Add sprite files
kielbasiago Nov 23, 2022
6cb41ec
ignore todo folder
kielbasiago Nov 23, 2022
74fc748
add sprite/palette select api files
kielbasiago Nov 25, 2022
5b844b0
add setup.py
kielbasiago Nov 25, 2022
38fde22
remove setup.py
kielbasiago Nov 25, 2022
bfc92ed
fix typos
kielbasiago Nov 25, 2022
d6d9a4d
breaking get_palettes, get_palettes_with-color
kielbasiago Nov 27, 2022
79fcee7
Update arguments to support lambdas
kielbasiago Nov 29, 2022
c16bd2a
rewrite metadata key to be flag
kielbasiago Dec 1, 2022
59a5e3f
remove args/__init__
kielbasiago Dec 3, 2022
44f1ba8
fix init
kielbasiago Dec 5, 2022
e489dd9
fix build-wc-flag-metadata
kielbasiago Dec 6, 2022
4268357
add group to objective metadata
kielbasiago Dec 18, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
__pycache__/
*.py[cod]
$py.class
*-objective.json
*-flag.json
10 changes: 10 additions & 0 deletions api/get_palette_bytes.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
def get_palette_bytes(palette_id):
from graphics.palettes.palettes import get_path as get_palette_path

return get_rgb_bytes(get_palette_path(palette_id))

def get_rgb_bytes(palette_path):
from graphics.palette_file import PaletteFile
palette = PaletteFile(palette_path)

return [(color.red, color.green, color.blue) for color in palette.colors]
30 changes: 30 additions & 0 deletions api/get_palettes.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
def get_palettes():
from graphics.palettes.palettes import id_palette
from api.get_palette_bytes import get_palette_bytes

palettes = [{
'id': palette_id,
'key': key,
} for ((palette_id, key)) in id_palette.items()]

return palettes

def get_palettes_with_colors():
from graphics.palettes.palettes import id_palette
from api.get_palette_bytes import get_palette_bytes

palettes = [{
'id': palette_id,
'key': key,
'palette': get_palette_bytes(palette_id)
} for ((palette_id, key)) in id_palette.items()]

return palettes

if __name__ == '__main__':
import os
import sys
sys.path.append(os.path.join(os.path.dirname(__file__), ".."))

import json
print(json.dumps(get_palettes()))
37 changes: 37 additions & 0 deletions api/get_sprite_base64.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
def get_sprite_base64(sprite_id, palette_id, pose_id):
from graphics.sprites.sprites import get_path as get_sprite_path
from graphics.palettes.palettes import get_path as get_palette_path

return get_base64(get_sprite_path(sprite_id), get_palette_path(palette_id), pose_id)

def get_base64(sprite_path, palette_path, pose_id):
from graphics.palette_file import PaletteFile
from graphics.sprite_file import SpriteFile
from graphics.poses import CHARACTER
palette = PaletteFile(palette_path)
sprite = SpriteFile(sprite_path, palette)
(r, g, b) = palette.alpha_rgb_data

image = sprite.get_ppm(CHARACTER[pose_id])
from PIL import Image
from io import BytesIO
import base64

png = Image.open(BytesIO(bytes(image))).convert('RGBA')
no_bg = Image.new('RGBA', png.size, (r, g, b, 0))

new_image = []
for item in png.getdata():
if item[:3] == (r, g, b):
new_image.append((255, 255, 255, 0))
else:
new_image.append(item)

no_bg.putdata(new_image)

io = BytesIO()
no_bg.save(io, format="PNG")
img_str = base64.b64encode(io.getvalue())
print(img_str.decode('utf-8'))
return img_str.decode('utf-8')

17 changes: 17 additions & 0 deletions api/get_sprite_bytes.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
def get_sprite_bytes(sprite_id, palette_id, pose_id):
from graphics.sprites.sprites import get_path as get_sprite_path
from graphics.palettes.palettes import get_path as get_palette_path

return get_rgb_bytes(get_sprite_path(sprite_id), get_palette_path(palette_id), pose_id)

def get_rgb_bytes(sprite_path, palette_path, pose_id):
from graphics.palette_file import PaletteFile
from graphics.sprite_file import SpriteFile
from graphics.poses import CHARACTER
palette = PaletteFile(palette_path)

sprite = SpriteFile(sprite_path, palette)

rgb_bytes = sprite.rgb_data(CHARACTER[pose_id])
alpha_bytes = palette.alpha_rgb_data
return (rgb_bytes, alpha_bytes)
38 changes: 38 additions & 0 deletions api/get_sprite_palette_bytes.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
def get_sprite_palette_bytes(sprite_id, palette_id, pose_id):
from graphics.sprites.sprites import get_path as get_sprite_path
from graphics.palettes.palettes import get_path as get_palette_path
from graphics.palette_file import PaletteFile
from graphics.sprite_file import SpriteFile
from graphics.poses import CHARACTER

palette = PaletteFile(get_palette_path(palette_id))
sprite = SpriteFile(get_sprite_path(sprite_id), palette)

palette_bytes = [(color.red, color.green, color.blue) for color in palette.colors]
sprite_bytes = [item for sublist in sprite.tile_matrix(CHARACTER[pose_id]) for item in sublist]

return (sprite_bytes, palette_bytes)

if __name__ == '__main__':
import os
import sys
sys.path.append(os.path.join(os.path.dirname(__file__), ".."))

import argparse
parser = argparse.ArgumentParser()
parser.add_argument("sprite_id", type=int,
help="Id of the sprite to print")
parser.add_argument("palette_id", type=int,
help="Id of the palette for the sprite")
parser.add_argument("pose_id", type=int,
help="Id of the pose for the sprite", default=1)

args = parser.parse_args()

(sprite, palette) = get_sprite_palette_bytes(args.sprite_id, args.palette_id, args.pose_id)

import json
print(json.dumps({
'sprite': sprite,
'palette': palette,
}))
17 changes: 17 additions & 0 deletions api/get_sprites.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
def get_sprites():
from graphics.sprites.sprites import id_sprite

sprites = [{
'id': sprite_id,
'key': key,
} for ((sprite_id, key)) in id_sprite.items()]

return sprites

if __name__ == '__main__':
import os
import sys
sys.path.append(os.path.join(os.path.dirname(__file__), ".."))

import json
print(json.dumps(get_sprites()))
6 changes: 3 additions & 3 deletions args/arguments.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@

class Arguments:
def __init__(self):
import importlib
self.groups = [
"settings",
"objectives",
"starting_party", "characters", "swdtechs", "blitzes", "lores", "rages", "dances", "steal", "commands",
"starting_party", "characters", "swdtechs", "blitzes", "lores", "rages", "dances", "steal", "commands",
"xpmpgp", "scaling", "bosses", "encounters", "boss_ai",
"espers", "natural_magic",
"starting_gold_items", "items", "shops", "chests",
Expand All @@ -30,7 +31,7 @@ def __init__(self):
group.parse(self.parser)

self.parser.parse_args(namespace = self)

self.flags = ""
self.seed_rng_flags = ""
for group_name, group in self.group_modules.items():
Expand All @@ -57,7 +58,6 @@ def __init__(self):
# ignore any output_file argument and add given seed id to output name
name, ext = os.path.splitext(self.input_file)
self.output_file = f"{name}wc_{self.seed_id}{ext}"

self.website_link = f"ff6wc.com/seed/{self.seed_id}"
elif self.output_file is None:
# if no output_file given add seed to output name
Expand Down
1 change: 1 addition & 0 deletions args/bosses.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ def parse(parser):
bosses = parser.add_argument_group("Bosses")

bosses_battles = bosses.add_mutually_exclusive_group()
bosses_battles.title = 'Boss Battles'
bosses_battles.add_argument("-bbs", "--boss-battles-shuffle", action = "store_true",
help = "Boss battles shuffled")
bosses_battles.add_argument("-bbr", "--boss-battles-random", action = "store_true",
Expand Down
2 changes: 2 additions & 0 deletions args/chests.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ def parse(parser):
chests = parser.add_argument_group("Chests")

chests_contents = chests.add_mutually_exclusive_group()
chests_contents.title = 'Chest Contents'

chests_contents.add_argument("-ccsr", "--chest-contents-shuffle-random", default = None, type = int,
metavar = "PERCENT", choices = range(101),
help = "Chest contents shuffled and given percent randomized")
Expand Down
4 changes: 4 additions & 0 deletions args/coliseum.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,16 @@ def parse(parser):
coliseum = parser.add_argument_group("Coliseum")

coliseum_opponents = coliseum.add_mutually_exclusive_group()
coliseum_opponents.title = 'Coliseum Opponents'

coliseum_opponents.add_argument("-cos", "--coliseum-opponents-shuffle", action = "store_true",
help = "Coliseum opponents shuffled")
coliseum_opponents.add_argument("-cor", "--coliseum-opponents-random", action = "store_true",
help = "Coliseum opponents randomized")

coliseum_rewards = coliseum.add_mutually_exclusive_group()
coliseum_rewards.title = 'Coliseum Rewards'

coliseum_rewards.add_argument("-crs", "--coliseum-rewards-shuffle", action = "store_true",
help = "Coliseum rewards shuffled")
coliseum_rewards.add_argument("-crr", "--coliseum-rewards-random", action = "store_true",
Expand Down
3 changes: 3 additions & 0 deletions args/encounters.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,21 @@ def parse(parser):
encounters = parser.add_argument_group("Encounters")

random = encounters.add_mutually_exclusive_group()
random.title = 'Random Encounters'
random.add_argument("-res", "--random-encounters-shuffle", action = "store_true",
help = "Random encounters are shuffled")
random.add_argument("-rer", "--random-encounters-random",
default = None, type = int, metavar = "PERCENT", choices = range(101),
help = "Random encounters are randomized")

fixed = encounters.add_mutually_exclusive_group()
fixed.title = 'Fixed Encounters'
fixed.add_argument("-fer", "--fixed-encounters-random",
default = None, type = int, metavar = "PERCENT", choices = range(101),
help = "Fixed encounters are randomized. Lete River, Serpent Trench, Mine Cart, Imperial Camp, ...")

escapable = encounters.add_mutually_exclusive_group()
escapable.title = 'Escapable Encounters'
escapable.add_argument("-escr", "--encounters-escapable-random",
default = None, type = int, metavar = "PERCENT", choices = range(101),
help = "Percent of random encounters escapable including with warp or smoke bombs")
Expand Down
4 changes: 4 additions & 0 deletions args/espers.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ def parse(parser):
espers = parser.add_argument_group("Espers")

esper_spells = espers.add_mutually_exclusive_group()
esper_spells.title = 'Esper Spells'
esper_spells.add_argument("-esrr", "--esper-spells-random-rates", action = "store_true",
help = "Original esper spells with random learn rates")
esper_spells.add_argument("-ess", "--esper-spells-shuffle", action = "store_true",
Expand All @@ -20,13 +21,15 @@ def parse(parser):
help = "Esper spells and learn rates randomized by tier")

esper_bonuses = espers.add_mutually_exclusive_group()
esper_bonuses.title = 'Esper Bonuses'
esper_bonuses.add_argument("-ebs", "--esper-bonuses-shuffle", action = "store_true",
help = "Esper bonuses shuffled")
esper_bonuses.add_argument("-ebr", "--esper-bonuses-random",
default = None, type = int, metavar = "PERCENT", choices = range(101),
help = "Esper bonuses randomized")

esper_mp = espers.add_mutually_exclusive_group()
esper_mp.title = 'Esper MP'
esper_mp.add_argument("-emps", "--esper-mp-shuffle", action = "store_true",
help = "Esper MP costs shuffled")
esper_mp.add_argument("-emprv", "--esper-mp-random-value", default = None, type = int,
Expand All @@ -37,6 +40,7 @@ def parse(parser):
help = "Each esper's MP cost set to random percent of original within given range")

esper_equipable = espers.add_mutually_exclusive_group()
esper_equipable.title = 'Equipable Espers'
esper_equipable.add_argument("-eer", "--esper-equipable-random",
default = None, type = int, nargs = 2, metavar = ("MIN", "MAX"),
choices = range(Characters.CHARACTER_COUNT - 1), # exclude gogo/umaro
Expand Down
2 changes: 2 additions & 0 deletions args/items.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ def parse(parser):
items = parser.add_argument_group("Items")

items_equipable = items.add_mutually_exclusive_group()
items_equipable.title = 'Equipable Items'
items_equipable.add_argument("-ier", "--item-equipable-random",
default = None, type = int, nargs = 2, metavar = ("MIN", "MAX"),
choices = range(Characters.CHARACTER_COUNT + 1),
Expand All @@ -22,6 +23,7 @@ def parse(parser):
help = "Shuffle character equipment. After randomization, characters have a %(metavar)s chance of being able to equip each item they could not previously equip. If %(metavar)s negative, characters have a -%(metavar)s chance of not being able to equip each item they could previously equip")

items_equipable_relic = items.add_mutually_exclusive_group()
items_equipable_relic.title = 'Equipable Relics'
items_equipable_relic.add_argument("-ierr", "--item-equipable-relic-random",
default = None, type = int, nargs = 2, metavar = ("MIN", "MAX"),
choices = range(Characters.CHARACTER_COUNT + 1),
Expand Down
1 change: 1 addition & 0 deletions args/lores.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ def parse(parser):
help = "Start with random lores learned")

lores_mp = lores.add_mutually_exclusive_group()
lores_mp.title = 'Lores'
lores_mp.add_argument("-lmps", "--lores-mp-shuffle", action = "store_true",
help = "Lore MP costs shuffled")
lores_mp.add_argument("-lmprv", "--lores-mp-random-value", default = None, type = int,
Expand Down
3 changes: 3 additions & 0 deletions args/misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,14 @@ def parse(parser):
help = "All enemies scannable. All characters start with scan learned. Scan costs 0 MP. Useful for testing/debugging")

event_timers = misc.add_mutually_exclusive_group()
event_timers.title = 'Event Timers'
event_timers.add_argument("-etr", "--event-timers-random", action = "store_true",
help = "Collapsing House, Opera House, and Floating Continent timers randomized")
event_timers.add_argument("-etn", "--event-timers-none", action = "store_true",
help = "Collapsing House, Opera House, and Floating Continent timers removed")

y_npc = misc.add_mutually_exclusive_group()
y_npc.title = 'Y NPC'
y_npc.add_argument("-ymascot", "--y-npc-mascot", action = "store_true",
help = "Transform NPC into random mascot")
y_npc.add_argument("-ycreature", "--y-npc-creature", action = "store_true",
Expand All @@ -44,6 +46,7 @@ def parse(parser):
parser.y_npc_group = y_npc

remove_flashes = misc.add_mutually_exclusive_group()
remove_flashes.title = 'Remove Flashes'
remove_flashes.add_argument("-frw", "--flashes-remove-worst", action = "store_true",
help = "Removes only the worst flashes from animations. Ex: Learning Bum Rush, Bum Rush, Quadra Slam/Slice, Flash, etc.")
remove_flashes.add_argument("-frm", "--flashes-remove-most", action = "store_true",
Expand Down
4 changes: 4 additions & 0 deletions args/scaling.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ def parse(parser):
scaling = parser.add_argument_group("Scaling")

level_scaling = scaling.add_mutually_exclusive_group()
level_scaling.title = 'Level Scaling'
level_scaling.add_argument("-lsa", "--level-scaling-average", default = None, type = float,
metavar = ("VALUE"), choices = [x / 10.0 for x in range(5, 55, 5)],
help = "Enemy and boss levels equal to %(metavar)s * party average level")
Expand All @@ -25,6 +26,7 @@ def parse(parser):
help = "Enemies and bosses gain 1 level every %(metavar)s minutes")

hp_mp_scaling = scaling.add_mutually_exclusive_group()
hp_mp_scaling.title = 'HP/MP Scaling'
hp_mp_scaling.add_argument("-hma", "--hp-mp-scaling-average", default = None, type = float,
metavar = ("VALUE"), choices = [x / 10.0 for x in range(5, 55, 5)],
help = "Enemy and boss hp/mp scales %(metavar)s * party averaage level")
Expand All @@ -45,6 +47,7 @@ def parse(parser):
help = "Enemy and boss hp/mp scales every %(metavar)s minutes")

xp_gp_scaling = scaling.add_mutually_exclusive_group()
xp_gp_scaling.title = 'XP/GP Scaling'
xp_gp_scaling.add_argument("-xga", "--xp-gp-scaling-average", default = None, type = float,
metavar = ("VALUE"), choices = [x / 10.0 for x in range(5, 55, 5)],
help = "Enemy and boss exp/gp scales %(metavar)s * party averaage level")
Expand All @@ -65,6 +68,7 @@ def parse(parser):
help = "Enemy and boss exp/gp scales every %(metavar)s minutes")

ability_scaling = scaling.add_mutually_exclusive_group()
ability_scaling.title = 'Ability Scaling'
ability_scaling.add_argument("-ase", "--ability-scaling-element", default = None, type = float,
metavar = ("VALUE"), choices = [x / 10.0 for x in range(5, 55, 5)],
help = "Enemy and boss abilities retain element and increase in tier approximately every (%(metavar)s + 3) levels reaching max tier at level (%(metavar)s + 3) * 8")
Expand Down
7 changes: 6 additions & 1 deletion args/settings.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
from argparse import ArgumentParser


def name():
return "Settings"

def parse(parser):
def parse(parser: ArgumentParser):
mode = parser.add_mutually_exclusive_group()
mode.title = 'Game Mode'

mode.add_argument("-open", "--open-world", action = "store_true",
help = "Unrestricted event access")
mode.add_argument("-cg", "--character-gating", action = "store_true",
Expand Down
3 changes: 3 additions & 0 deletions args/shops.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ def parse(parser):
shops = parser.add_argument_group("Shops")

shops_inventory = shops.add_mutually_exclusive_group()
shops_inventory.title = 'Shop Inventory'
shops_inventory.add_argument("-sisr", "--shop-inventory-shuffle-random",
default = None, type = int, metavar = "PERCENT", choices = range(101),
help = "Shop inventories randomized based on type. All weapon shops randomized, all armor shops, etc...")
Expand All @@ -14,6 +15,7 @@ def parse(parser):
help = "Shop inventories empty")

shops_prices = shops.add_mutually_exclusive_group()
shops_prices.title = 'Shop Prices'
shops_prices.add_argument("-sprv", "--shop-prices-random-value", default = None, type = int,
nargs = 2, metavar = ("MIN", "MAX"), choices = range(2**16),
help = "Each item cost set to random value within given range")
Expand All @@ -22,6 +24,7 @@ def parse(parser):
help = "Each item cost set to random percent of original within given range")

shops_sell_fraction = shops.add_mutually_exclusive_group()
shops_sell_fraction.title = 'Shop Sell Fraction'
shops_sell_fraction.add_argument("-ssf4", "--shop-sell-fraction4", action = "store_true",
help = "Items sell for 1/4 their price")
shops_sell_fraction.add_argument("-ssf8", "--shop-sell-fraction8", action = "store_true",
Expand Down
Loading