import { CompleteChecklist } from "~/composables/Checklist" ; import { computed , ref } from "vue" ; import { useState } from "~/State" ; export enum Class { Beginner = "Beginner" , Journeyman = "Journeyman" , Maestro = "Maestro" , Warrior = "Warrior" , Barbarian = "Barbarian" , Squire = "Squire" , Archer = "Archer" , Bowman = "Bowman" , Hunter = "Hunter" , Mage = "Mage" , Wizard = "Wizard" , Shaman = "Shaman" } export const BaseClass = [ Class . Beginner , Class . Warrior , Class . Archer , Class . Mage , ] ; export const Subclass = { [ Class . Beginner ] : [ Class . Journeyman ] , [ Class . Journeyman ] : [ Class . Maestro ] , [ Class . Maestro ] : [ ] , [ Class . Warrior ] : [ Class . Barbarian , Class . Squire ] , [ Class . Barbarian ] : [ ] , [ Class . Squire ] : [ ] , [ Class . Archer ] : [ Class . Bowman , Class . Hunter ] , [ Class . Bowman ] : [ ] , [ Class . Hunter ] : [ ] , [ Class . Mage ] : [ Class . Wizard , Class . Shaman ] , [ Class . Wizard ] : [ ] , [ Class . Shaman ] : [ ] , } ; export const Superclass = { [ Class . Journeyman ] : Class . Beginner , [ Class . Maestro ] : Class . Journeyman , [ Class . Warrior ] : Class . Beginner , [ Class . Barbarian ] : Class . Warrior , [ Class . Squire ] : Class . Warrior , [ Class . Archer ] : Class . Beginner , [ Class . Bowman ] : Class . Archer , [ Class . Hunter ] : Class . Archer , [ Class . Mage ] : Class . Beginner , [ Class . Wizard ] : Class . Mage , [ Class . Shaman ] : Class . Mage , } ; export const getClassTree = ( class_ ) : Class [ ] => { const classes = [ ] ; let current = class_ ; while ( current ) { classes . push ( current ) ; current = Superclass [ current ] ; } return classes ; } ; export const Skills = [ "Mining" , "Fishing" , "Trapping" , "Smithing" , "Alchemy" , "Construction" , "Choppin'" , "Catching" , "Worship" , ] as const ; export type Skill = typeof Skills [ number ] ; export class Character { public class : Class ; public level : number ; public name : string ; public constellations : Record < string , boolean > ; public items : Record < string , boolean > ; public quests : Record < string , boolean > ; public skills : Record < Skill , number > ; public starSigns : Record < string , boolean > ; constructor ( ) { this . class = Class . Beginner ; this . level = 1 ; this . name = "" ; this . constellations = { } ; this . items = { } ; this . quests = { } ; this . skills = < Record < Skill , number > > ( Object . fromEntries ( Skills . map ( ( x ) => [ x , 0 ] ) ) ) ; this . starSigns = { } ; } get bagSlots ( ) : number { let slots = 16 ; const { checklist } = useState ( ) . value ; for ( const category of [ "Inventory Bags" ] as const ) { for ( const item of CompleteChecklist [ category ] [ 0 ] . items ) { if ( this . hasItem ( item . name ) ) { slots += item . bagSlots ?? 0 ; } } } for ( const category of [ "Gem Shop Bags" ] as const ) { for ( const item of CompleteChecklist [ category ] [ 0 ] . items ) { if ( checklist [ item . name ] === true ) { slots += item . bagSlots ?? 0 ; } } } return slots ; } hasItem ( item ) { return this . items [ item ] === true ; } } const charIndex = ref ( 0 ) ; export function useCharacters ( ) { const state = useState ( ) ; const characters = computed ( { get : ( ) => state . value . chars , set : ( value ) => ( state . value . chars = value ) , } ) ; const numCharacters = computed ( ( ) => { return characters . value . length ; } ) ; const currentCharacter = computed < Character | null > ( ( ) => { if ( numCharacters . value > 0 ) { return characters . value [ charIndex . value ] ; } return null ; } ) ; const createCharactersFromData = ( data ) => { characters . value = [ ] ; for ( const c of data ) { const newChar = new Character ( ) ; Object . assign ( newChar , c ) ; characters . value . push ( newChar ) ; } } ; const createNewCharacter = ( ) => { characters . value . push ( new Character ( ) ) ; charIndex . value = characters . value . length - 1 ; } ; const deleteCurrentCharacter = ( ) => { characters . value . splice ( charIndex . value , 1 ) ; charIndex . value = 0 ; } ; const nextCharacter = ( ) => { if ( numCharacters . value > 0 ) { charIndex . value = ( charIndex . value + 1 ) % numCharacters . value ; } } ; const prevCharacter = ( ) => { if ( numCharacters . value > 0 ) { charIndex . value = ( charIndex . value - 1 ) % numCharacters . value ; } } ; const switchToCharacter = ( i ) => { if ( i < 0 || i > characters . value . length ) { return ; } charIndex . value = i ; } ; return { characters , createCharactersFromData , createNewCharacter , currentCharacter , deleteCurrentCharacter , numCharacters , nextCharacter , prevCharacter , switchToCharacter , } ; } export enum WeaponType { Fisticuff , Spear , Bow , Wand } export function useCombat ( ) { const attackSpeed = ( weaponSpeed , weaponType ) => { const weaponStats = { [ WeaponType . Fisticuff ] : { base : 650 , cap : 300 , delay : 13 , } , [ WeaponType . Spear ] : { base : 650 , cap : 300 , delay : 13 , } , [ WeaponType . Bow ] : { base : 850 , cap : 750 , delay : 13.5 , } , [ WeaponType . Wand ] : { base : 760 , cap : 600 , delay : 16 , } , } ; const stats = weaponStats [ weaponType ] ; return Math . max ( stats . base + ( stats . delay - weaponSpeed ) / 5 , stats . cap ) ; } ; return { attackSpeed , } ; }