Skip to content

Commit

Permalink
Merge pull request #36 from Savage-Aim/abyssos-prep
Browse files Browse the repository at this point in the history
prepping numbers and gear for abyssos release
  • Loading branch information
freyamade authored Aug 23, 2022
2 parents 1c3ba55 + d4674a9 commit 2653da3
Show file tree
Hide file tree
Showing 24 changed files with 346 additions and 236 deletions.
14 changes: 0 additions & 14 deletions backend/api/management/commands/all_seed.py

This file was deleted.

44 changes: 0 additions & 44 deletions backend/api/management/commands/gear_seed.py

This file was deleted.

43 changes: 0 additions & 43 deletions backend/api/management/commands/job_seed.py

This file was deleted.

64 changes: 64 additions & 0 deletions backend/api/management/commands/seed.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
# lib
import yaml
from django.conf import settings
from django.core.management.base import BaseCommand
from django.db import IntegrityError, transaction
# local
from api import models


class Command(BaseCommand):
help = 'Seed the DB with static data for Gear, Tier and Job information.'

def handle(self, *args, **options):
self.stdout.write(self.style.HTTP_REDIRECT('Beginning Seed of DB'))
seed_data_dir = settings.BASE_DIR / 'api/management/commands/seed_data'

# Get the Tier and Gear data and import them
with open(seed_data_dir / 'gear.yml', 'r') as f:
self.stdout.write(self.style.HTTP_REDIRECT('Seeding Gear'))
self.import_file(f, models.Gear)

with open(seed_data_dir / 'tiers.yml', 'r') as f:
self.stdout.write(self.style.HTTP_REDIRECT('Seeding Tiers'))
self.import_file(f, models.Tier)

# Lastly we import the Job data.
# This is handled *slightly* differently because the 'ordering' key in this file will most likely change
# between expansions, especially for dps
# So this Integrity Error will be handled slightly differently

with open(seed_data_dir / 'jobs.yml', 'r') as f:
self.stdout.write(self.style.HTTP_REDIRECT('Seeding Jobs'))
self.import_jobs(f)

def import_file(self, file, model):
data = yaml.safe_load(file)
for item in data:
self.stdout.write(f'\t{item["name"]}')
try:
with transaction.atomic():
model.objects.create(**item)
except IntegrityError:
self.stdout.write('\t\tSkipping, as it is already in the DB.')

def import_jobs(self, file):
"""
Import Job data.
If Job exists, ensure the ordering value is up to date
"""
data = yaml.safe_load(file)
for job in data:
self.stdout.write(f'\t{job["id"]}')

# Check if the Job is already in the Database
try:
obj = models.Job.objects.get(pk=job['id'])
self.stdout.write(
f'\t\tAlready exists, ensuring correct ordering ({obj.ordering} -> {job["ordering"]})',
)
obj.ordering = job['ordering']
obj.save()
except models.Job.DoesNotExist:
# If it doesn't exist, just create it!
models.Job.objects.create(**job)
121 changes: 121 additions & 0 deletions backend/api/management/commands/seed_data/gear.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
# 6.2
- has_accessories: True
has_armour: True
has_weapon: True
item_level: 610
name: 'Rinascita'
- has_accessories: True
has_armour: True
has_weapon: False
item_level: 610
name: 'Purgatory'
- has_accessories: False
has_armour: False
has_weapon: True
item_level: 615
name: 'Windswept'
- has_accessories: True
has_armour: True
has_weapon: True
item_level: 620
name: 'Lunar Envoy'
- has_accessories: True
has_armour: True
has_weapon: True
item_level: 630
name: 'Augmented Lunar Envoy'
- has_accessories: True
has_armour: True
has_weapon: False
item_level: 630
name: 'Abyssos'
- has_accessories: False
has_armour: False
has_weapon: True
item_level: 635
name: 'Abyssos'

# 6.1.1
- has_accessories: False
has_armour: False
has_weapon: True
item_level: 605
name: 'Ultimate of the Heavens'

# 6.1
- has_accessories: False
has_armour: True
has_weapon: False
item_level: 590
name: 'Panthean'
- has_accessories: False
has_armour: False
has_weapon: True
item_level: 595
name: 'Bluefeather'
- has_accessories: True
has_armour: True
has_weapon: True
item_level: 590
name: 'Augmented Classical'

# 6.0.5
- has_accessories: True
has_armour: True
has_weapon: True
item_level: 580
name: 'Classical'
- has_accessories: True
has_armour: True
has_weapon: True
item_level: 590
name: 'Radiant Host'
- has_accessories: True
has_armour: True
has_weapon: True
item_level: 600
name: 'Augmented Radiant Host'
- has_accessories: True
has_armour: True
has_weapon: False
item_level: 600
name: 'Asphodelos'
- has_accessories: False
has_armour: False
has_weapon: True
item_level: 605
name: 'Asphodelos'

# 6.0.1
- has_accessories: True
has_armour: True
has_weapon: False
item_level: 580
name: 'Limbo'

# 6.0
- has_accessories: true
has_armour: false
has_weapon: false
item_level: 560
name: 'The Last'
- has_accessories: false
has_armour: True
has_weapon: True
item_level: 560
name: 'Endwalker AF'
- has_accessories: True
has_armour: True
has_weapon: True
item_level: 570
name: 'Moonward'
- has_accessories: True
has_armour: False
has_weapon: False
item_level: 580
name: 'Eternal Dark'
- has_accessories: False
has_armour: False
has_weapon: True
item_level: 580
name: 'Divine Light'
104 changes: 104 additions & 0 deletions backend/api/management/commands/seed_data/jobs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
# Tanks
- name: 'paladin'
id: 'PLD'
display_name: 'Paladin'
ordering: 0
role: 'tank'
- name: 'warrior'
id: 'WAR'
display_name: 'Warrior'
ordering: 1
role: 'tank'
- name: 'darkknight'
id: 'DRK'
display_name: 'Dark Knight'
ordering: 2
role: 'tank'
- name: 'gunbreaker'
id: 'GNB'
display_name: 'Gunbreaker'
ordering: 3
role: 'tank'

# Healers
- name: 'whitemage'
id: 'WHM'
display_name: 'White Mage'
ordering: 0
role: 'heal'
- name: 'scholar'
id: 'SCH'
display_name: 'Scholar'
ordering: 1
role: 'heal'
- name: 'astrologian'
id: 'AST'
display_name: 'Astrologian'
ordering: 2
role: 'heal'
- name: 'sage'
id: 'SGE'
display_name: 'Sage'
ordering: 3
role: 'heal'

# Melee
- name: 'monk'
id: 'MNK'
display_name: 'Monk'
ordering: 0
role: 'dps'
- name: 'dragoon'
id: 'DRG'
display_name: 'Dragoon'
ordering: 1
role: 'dps'
- name: 'ninja'
id: 'NIN'
display_name: 'Ninja'
ordering: 2
role: 'dps'
- name: 'samurai'
id: 'SAM'
display_name: 'Samurai'
ordering: 3
role: 'dps'
- name: 'reaper'
id: 'RPR'
display_name: 'Reaper'
ordering: 4
role: 'dps'

# Phys Ranged
- name: 'bard'
id: 'BRD'
display_name: 'Bard'
ordering: 5
role: 'dps'
- name: 'machinist'
id: 'MCH'
display_name: 'Machinist'
ordering: 6
role: 'dps'
- name: 'dancer'
id: 'DNC'
display_name: 'Dancer'
ordering: 7
role: 'dps'

# Casters
- name: 'blackmage'
id: 'BLM'
display_name: 'Black Mage'
ordering: 8
role: 'dps'
- name: 'summoner'
id: 'SMN'
display_name: 'Summoner'
ordering: 9
role: 'dps'
- name: 'redmage'
id: 'RDM'
display_name: 'Red Mage'
ordering: 10
role: 'dps'
Loading

0 comments on commit 2653da3

Please sign in to comment.