# doc

This is documentation relevant to the project.
SQL files are master.mdb dumps labeled by date and region.
This file is my notes from exploring the database.

# text_data categories

- 6 is character names, 4 is [variant] character name, 5 is [variant], 14 is variant
- 47 is skill names, 48 is skill descriptions
- 75 is support card names incl. variant, 76 is support card variant, 77 is support card character
- 147 is spark names, 172 is spark descriptions
- 33 is race names by race id, 28 is race names by race instance id, 31 is race courses
- 65 is player titles, 66 is title descriptions - ties with honor_data?

# succession factor (sparks)

tables are succession_factor and succession_factor_effect

factor_type:
- 1 stat
- 2 aptitude
- 5 race
- 4 skill
- 6 scenario
- 3 unique

target_type:
- 1 speed; value 1 is amount, value 2 is 0
- 2 stam
- 3 power
- 4 guts
- 5 wit
- 11 turf; value 1 is number of levels (1 or 2), value 2 is 0
- 12 dirt
- 21 front
- 22 pace
- 23 late
- 24 end
- 31 sprint
- 32 mile
- 33 medium
- 34 long
- 41 is skill; value 1 is skill id, value 2 is hint level (1-5)

every possible result has a row in succession_factor_effect.
effect_id distinguishes possibilities; factors with multiple effects (race and scenario sparks) have multiple rows with equal effect_id.
effect_group_id determines the pmf, but no tables have non-empty joins with the same column name, so the distribution values are mystery.
even searching for 51 and 52 (effect group ids for 1\* and 2\* race and scenario sparks) on consecutive lines gives nothing.

sf.grade = 1 unless it is a unique (green) spark, then sf.grade = 2.
=> sf.grade = 2 iff sf.factor_type = 3

getting all interesting spark data, fully expanded with all effects:
```sql
WITH spark AS (
    SELECT
        n."index" AS "id",
        n."text" AS "name",
        d."text" AS "description"
    FROM text_data n
        LEFT JOIN text_data d ON n."index" = d."index" AND d."category" = 172
    WHERE n.category = 147
)
SELECT
    spark.name,
    spark.description,
    sf.factor_id,
    sf.factor_group_id,
    sf.factor_type,
    sf.effect_group_id,
    sfe.effect_id,
    sfe.target_type,
    sfe.value_1,
    sfe.value_2
FROM spark
    JOIN succession_factor sf ON spark.id = sf.factor_id
    JOIN succession_factor_effect sfe ON sf.factor_group_id = sfe.factor_group_id
ORDER BY sf.factor_id, sfe.effect_id, sfe.target_type
```

(change joins to left to include sparks that aren't implemented yet, mostly uniques)

getting all skills' levels that each spark can give:
```sql
WITH spark AS (
    SELECT
        n."index" AS "id",
        n."text" AS "name",
        d."text" AS "description"
    FROM text_data n
        LEFT JOIN text_data d ON n."index" = d."index" AND d."category" = 172
    WHERE n.category = 147
), spark_skills AS (
    SELECT DISTINCT
        factor_group_id,
        value_1,
        value_2
    FROM succession_factor_effect
    WHERE target_type = 41
)
SELECT
    spark.name,
    spark.description,
    sf.factor_id,
    sf.factor_group_id,
    sf.factor_type,
    sf.effect_group_id,
    ss.value_1 AS skill,
    JSON_GROUP_ARRAY(ss.value_2) AS levels
FROM spark
    JOIN succession_factor sf ON spark.id = sf.factor_id
    JOIN spark_skills ss ON sf.factor_group_id = ss.factor_group_id
GROUP BY sf.factor_id
ORDER BY sf.factor_id
```
although realistically you can just use effect_group_id to determine both probabilities and support.
race sparks with skills always give +1, skill sparks always give +1-5, unique sparks always give +1-3.

# support cards

- hints are defined in single_mode_hint_gain, grouped by hint_group
- hint_gain_type is 0 for skill, 1 for stat or skill points
- hint_value_1 is skill id or stat target 1 = speed 2 = stam ... 5 = guts; 30 = skill points
- hint_value_2 appears to be base skill hint level (1 always) or stat amount (6, 2, 1 for guts speed/pow, 5 for wit skill points)

# skills

- single_mode_skill_need_point is base number of skill points to buy each skill
- support card skill hints are defined in single_mode_hint_gain
- skill_set is NOT trainee skills, seems to be npcs
- available_skill_set has trainee starting skills

skill categories:
- 0 passive
- 1 early race
- 2 mid-race
- 3 late race or last spurt
- 4 anytime
- 5 unique

unique_skill_id_1 is for inherited uniques, points to non-inherited version.
unique_skill_id_2 is same but points to 1\*/2\* version.

exp_type appears to be whether the skill gains levels, i.e. own unique.

ability time and cooldown time are given in tenths of milliseconds, i.e. divide by 10000 to get seconds.

ability types:
- 1 speed bonus => ability_value / 10000 is flat gain
- 2 stamina bonus
- 3 power bonus
- 4 guts bonus
- 5 wit bonus
- 6 runaway => ability_value = 0
- 8 vision => ability_value / 10000 is amount (what are the units? what does vision do??)
- 9 heal or stam debuff => ability_value / 10000 is hp modify
- 10 starting gate delay (focus, concentration, gatekept) => ability_value / 10000 is multiplier
- 13 frenzy => ability_value / 10000 is rush time modifier (add?)
- 21 current speed => ability_value / 10000 is multiplier modifier
- 27 target speed => ''
- 28 lane change speed => ''
- 31 accel => ''
- 35 force lane change? it's only on dodging danger/sixth sense with a value of 5000 on both, gametora says "change lane (50% of the track)"

target types:
- 0 none (second and third abilities on skills that only have one)
- 1 self
- 2 others who have sympathy? only on autumn neo universe's rare green skill which triggers everyone's sympathy, and there's no target value
- 4 others in view
- 7 frontmost? only on daiichi ruby's unique, has a target value of 5 but the description says 先頭から4人まで
- 9 others ahead, target_value is number of targets (18 for all)
- 10 others behind, target_value is number of targets
- 11 all teammates
- 18 others in style, target_value is style (1=front, 2=pace, 3=late, 4=end)
- 19 rushing others ahead
- 20 rushing others behind
- 21 rushing others in style, target_value is style
- 22 specific character, target value is character id
- 23 other who triggered the skill

TODO target types only in jp: 2, 7, 11, 22, 23

ability_value_usage can be 1 for plain or 2-6 for aoharu stat skill stat scaling

seems to be activate_lot = 1 means wit check, 0 means guaranteed

# races

- group 1, grade: g1 100, g2 200, g3 300, op 400, pre-op 700
- group 61 is ....?? don't match anything
- several races are defined twice for "weird" races that appear in certain careers (maruzensky's 5 opponent spring stakes, mcqueen/ryan/rice's kyoto takarazuka kinen, &c.); these **do not** count as the same race as the normal versions for shared saddle bonus

single_mode_wins_saddle defines titles (classic triple crown, tenno sweep, &c.) using win_saddle_type = 0

# trainee definitions

- card_data has universal trainee stats: base skill set, stat growth bonuses ("talent"), default running style
- card_rarity_data has per-star-level stats: initial numbers, stat caps (!!), aptitudes (!!)
- card_talent_upgrade has costs to increase potential level, but it doesn't seem to have skill sets
- card_talent_hint_upgrade has costs to raise hint levels, but it's actually universal, only six rows
- single_mode_route_race is career goals (not only races)

# unrelated to everything

try doober with E long, all-seeing eyes, gold recovery, and lots of stamina running in g3 diamond stakes senior year late february
