#!/usr/bin/env python3
# -*- coding: utf-8 -*-
from typing import List, Dict, Tuple
import re
import math
import random
from collections import OrderedDict

from contents.character.Investigator import Investigator, SkillSet, InitialValueOfSkills

class CharacterAppearance():
    # SIZ:          0    1    2    3    4    5    6    7    8    9   10   11   12   13   14   15   16   17   18   19   20   21   22   23   24
    SIZ_HEIGHT = [105, 110, 115, 120, 125, 130, 135, 140, 145, 150, 155, 160, 165, 170, 175, 180, 185, 190, 195, 200, 205, 210, 215, 220, 225]
    SIZ_WEIGHT = [ 22,  25,  28,  31,  34,  37,  40,  43,  46,  50,  53,  56,  60,  64,  67,  71,  75,  79,  83,  87,  91,  95,  99, 103, 107]
    FLUCTUATION_HEIGHT_RANGE = [-5, -4, -3, -2, -1, -1, -1, -1, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 2, 3, 4, 5]
    FLUCTUATION_WEIGHT_RANGE = [-5, -4, -3, -2, -1, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 2, 3, 4, 5]

    # 和名色 参考サイト
    # https://www.colordic.org/w
    SUPER_RARE_COLOR = [
        "桜色(さくらいろ)","小豆色(あずきいろ)","黄金(こがね)","萌葱色(もえぎいろ)","古代紫(こだいむらさき)",
        "薄桜(うすざくら)","枯茶(からちゃ)","櫨染(はじぞめ)","花緑青(はなろくしょう)","茄子紺(なすこん)",
        "桜鼠(さくらねず)","飴色(あめいろ)","黄朽葉色(きくちばいろ)","翡翠色(ひすいいろ)","二藍(ふたあい)",
        "鴇鼠(ときねず)","駱駝色(らくだいろ)","山吹茶(やまぶきちゃ)","青緑(あおみどり)","京紫(きょうむらさき)",
        "虹色(にじいろ)","土色(つちいろ)","芥子色(からしいろ)","水浅葱(みずあさぎ)","蒲葡(えびぞめ)",
        "珊瑚色(さんごいろ)","黄唐茶(きがらちゃ)","豆がら茶(まめがらちゃ)","錆浅葱(さびあさぎ)","若紫(わかむらさき)",
        "一斤染(いっこんぞめ)","桑染(くわぞめ)","麹塵(きくじん)","青碧(せいへき)","紅紫(べにむらさき)",
        "宍色(ししいろ)","櫨色(はじいろ)","山鳩色(やまばといろ)","御召茶(おめしちゃ)","梅紫(うめむらさき)",
        "紅梅色(こうばいいろ)","黄橡(きつるばみ)","利休鼠(りきゅうねずみ)","湊鼠(みなとねずみ)","菖蒲色(あやめいろ)",
        "薄紅(うすべに)","丁字染(ちょうじぞめ)","海松茶(みるちゃ)","高麗納戸(こうらいなんど)","紅藤色(べにふじいろ)",
        "甚三紅(じんざもみ)","香染(こうぞめ)","藍海松茶(あいみるちゃ)","百入茶(ももしおちゃ)","浅紫(あさむらさき)",
        "桃色(ももいろ)","枇杷茶(びわちゃ)","藍媚茶(あいこびちゃ)","錆鼠(さびねず)","紫水晶(むらさきすいしょう)",
        "鴇色(ときいろ)","芝翫茶(しかんちゃ)","千歳茶(せんさいちゃ)","錆鉄御納戸(さびてつおなんど)","薄梅鼠(うすうめねず)",
        "撫子色(なでしこいろ)","焦香(こがれこう)","岩井茶(いわいちゃ)","藍鼠(あいねず)","暁鼠(あかつきねず)",
        "灰梅(はいうめ)","胡桃色(くるみいろ)","仙斎茶(せんさいちゃ)","錆御納戸(さびおなんど)","牡丹鼠(ぼたんねず)",
        "灰桜(はいざくら)","渋紙色(しぶかみいろ)","黒緑(くろみどり)","舛花色(ますはないろ)","霞色(かすみいろ)",
        "淡紅藤(あわべにふじ)","朽葉色(くちばいろ)","柳煤竹(やなぎすすたけ)","熨斗目花色(のしめはないろ)","藤鼠(ふじねず)",
        "石竹色(せきちくいろ)","桑茶(くわちゃ)","樺茶色(かばちゃいろ)","御召御納戸(おめしおなんど)","半色(はしたいろ)",
        "薄紅梅(うすこうばい)","路考茶(ろこうちゃ)","空五倍子色(うつぶしいろ)","鉄御納戸(てつおなんど)","薄色(うすいろ)",
        "桃花色(ももはないろ)","国防色(こくぼうしょく)","生壁色(なまかべいろ)","紺鼠(こんねず)","薄鼠(うすねず)",
        "水柿(みずがき)","伽羅色(きゃらいろ)","肥後煤竹(ひごすすたけ)","藍鉄(あいてつ)","鳩羽鼠(はとばねずみ)",
        "ときがら茶(ときがらちゃ)","江戸茶(えどちゃ)","媚茶(こびちゃ)","青褐(あおかち)","鳩羽色(はとばいろ)",
        "退紅(あらぞめ)","樺色(かばいろ)","白橡(しろつるばみ)","褐返(かちかえし)","桔梗鼠(ききょうねず)",
        "薄柿(うすがき)","紅鬱金(べにうこん)","亜麻色(あまいろ)","褐色(かちいろ)","紫鼠(むらさきねず)",
        "長春色(ちょうしゅんいろ)","土器色(かわらけいろ)","榛色(はしばみいろ)","月白(げっぱく)","葡萄鼠(ぶどうねずみ)",
        "梅鼠(うめねず)","狐色(きつねいろ)","灰汁色(あくいろ)","白菫色(しろすみれいろ)","濃色(こきいろ)",
        "鴇浅葱(ときあさぎ)","黄土色(おうどいろ)","利休茶(りきゅうちゃ)","白花色(しらはないろ)","紫鳶(むらさきとび)",
        "梅染(うめぞめ)","琥珀色(こはくいろ)","鶯茶(うぐいすちゃ)","藍白(あいじろ)","濃鼠(こいねず)",
        "蘇芳香(すおうこう)","赤茶(あかちゃ)","木蘭色(もくらんじき)","白藍(しらあい)","藤煤竹(ふじすすたけ)",
        "浅蘇芳(あさすおう)","代赭(たいしゃ)","砂色(すないろ)","水色(みずいろ)","滅紫(けしむらさき)",
        "真朱(まそお)","煉瓦色(れんがいろ)","油色(あぶらいろ)","瓶覗(かめのぞき)","紅消鼠(べにけしねずみ)",
        "赤紫(あかむらさき)","雀茶(すずめちゃ)","利休色(りきゅういろ)","秘色色(ひそくいろ)","似せ紫(にせむらさき)",
        "躑躅色(つつじいろ)","団十郎茶(だんじゅうろうちゃ)","梅幸茶(ばいこうちゃ)","空色(そらいろ)","灰黄緑(はいきみどり)",
        "牡丹色(ぼたんいろ)","柿渋色(かきしぶいろ)","璃寛茶(りかんちゃ)","勿忘草色(わすれなぐさいろ)","蕎麦切色(そばきりいろ)",
        "今様色(いまよういろ)","紅鳶(べにとび)","黄海松茶(きみるちゃ)","青藤色(あおふじいろ)","薄雲鼠(うすくもねず)",
        "中紅(なかべに)","灰茶(はいちゃ)","菜種油色(なたねゆいろ)","白群(びゃくぐん)","枯野色(かれのいろ)",
        "薔薇色(ばらいろ)","茶色(ちゃいろ)","青朽葉(あおくちば)","浅縹(あさはなだ)","潤色(うるみいろ)",
        "韓紅(からくれない)","檜皮色(ひわだいろ)","根岸色(ねぎしいろ)","薄花色(うすはないろ)","利休白茶(りきゅうしろちゃ)",
        "銀朱(ぎんしゅ)","鳶色(とびいろ)","鶸茶(ひわちゃ)","納戸色(なんどいろ)","茶鼠(ちゃねずみ)",
        "赤紅(あかべに)","柿茶(かきちゃ)","柳茶(やなぎちゃ)","浅葱色(あさぎいろ)","胡桃染(くるみぞめ)",
        "紅緋(べにひ)","弁柄色(べんがらいろ)","海松色(みるいろ)","花浅葱(はなあさぎ)","江戸鼠(えどねず)",
        "赤(あか)","赤錆色(あかさびいろ)","鶯色(うぐいすいろ)","新橋色(しんばしいろ)","煤色(すすいろ)",
        "猩々緋(しょうじょうひ)","褐色(かっしょく)","緑黄色(りょくおうしょく)","天色(あまいろ)","丁子茶(ちょうじちゃ)",
        "紅(くれない)","栗梅(くりうめ)","鶸色(ひわいろ)","露草色(つゆくさいろ)","柴染(ふしぞめ)",
        "深緋(こきひ)","紅檜皮(べにひはだ)","抹茶色(まっちゃいろ)","青(あお)","宗伝唐茶(そうでんからちゃ)",
        "緋色(ひいろ)","海老茶(えびちゃ)","若草色(わかくさいろ)","薄藍(うすあい)","砺茶(とのちゃ)",
        "赤丹(あかに)","唐茶(からちゃ)","黄緑(きみどり)","縹色(はなだいろ)","煎茶色(せんちゃいろ)",
        "紅赤(べにあか)","栗色(くりいろ)","若芽色(わかめいろ)","紺碧(こんぺき)","銀煤竹(ぎんすすだけ)",
        "臙脂(えんじ)","赤銅色(しゃくどういろ)","若菜色(わかないろ)","薄群青(うすぐんじょう)","黄枯茶(きがらちゃ)",
        "朱・緋(あけ)","錆色(さびいろ)","若苗色(わかなえいろ)","薄花桜(うすはなざくら)","煤竹色(すすたけいろ)",
        "茜色(あかねいろ)","赤褐色(せっかっしょく)","青丹(あおに)","群青色(ぐんじょういろ)","焦茶(こげちゃ)",
        "紅海老茶(べにえびちゃ)","茶褐色(ちゃかっしょく)","草色(くさいろ)","杜若色(かきつばたいろ)","黒橡(くろつるばみ)",
        "蘇芳(すおう)","栗皮茶(くりかわちゃ)","苔色(こけいろ)","瑠璃色(るりいろ)","憲法色(けんぽういろ)",
        "真紅(しんく)","黒茶(くろちゃ)","萌黄(もえぎ)","薄縹(うすはなだ)","涅色(くりいろ)",
        "濃紅(こいくれない)","葡萄茶(えびちゃ)","苗色(なえいろ)","瑠璃紺(るりこん)","檳榔子染(びんろうじぞめ)",
        "象牙色(ぞうげいろ)","葡萄色(えびいろ)","若葉色(わかばいろ)","紺瑠璃(こんるり)","黒鳶(くろとび)",
        "練色(ねりいろ)","萱草色(かんぞういろ)","松葉色(まつばいろ)","藍色(あいいろ)","赤墨(あかすみ)",
        "灰白色(かいはくしょく)","柑子色(こうじいろ)","夏虫色(なつむしいろ)","青藍(せいらん)","黒紅(くろべに)",
        "蒸栗色(むしぐりいろ)","金茶(きんちゃ)","鶸萌黄(ひわもえぎ)","深縹(こきはなだ)","白(しろ)",
        "女郎花(おみなえし)","蜜柑色(みかんいろ)","柳色(やなぎいろ)","紺色(こんいろ)","胡粉色(ごふんいろ)",
        "枯草色(かれくさいろ)","鉛丹色(えんたんいろ)","青白橡(あおしろつるばみ)","紺青(こんじょう)","卯の花色(うのはないろ)",
        "淡黄(たんこう)","黄丹(おうに)","柳鼠(やなぎねず)","留紺(とめこん)","白磁(はくじ)",
        "白茶(しらちゃ)","柿色(かきいろ)","裏葉柳(うらはやなぎ)","濃藍(こいあい)","生成り色(きなりいろ)",
        "赤白橡(あかしろつるばみ)","黄赤(きあか)","山葵色(わさびいろ)","鉄紺(てつこん)","乳白色(にゅうはくしょく)",
        "洗柿(あらいがき)","人参色(にんじんいろ)","老竹色(おいたけいろ)","漆黒(しっこく)","白練(しろねり)",
        "鳥の子色(とりのこいろ)","橙色(だいだいいろ)","白緑(びゃくろく)","淡藤色(あわふじいろ)","素色(そしょく)",
        "蜂蜜色(はちみついろ)","照柿(てりがき)","淡萌黄(うすもえぎ)","藤色(ふじいろ)","白梅鼠(しらうめねず)",
        "肌色(はだいろ)","赤橙(あかだいだい)","柳染(やなぎぞめ)","紅掛空色(べにかけそらいろ)","白鼠(しろねず)",
        "薄卵色(うすたまごいろ)","金赤(きんあか)","薄萌葱(うすもえぎ)","紅碧(べにみどり)","絹鼠(きぬねず)",
        "雄黄(ゆうおう)","朱色(しゅいろ)","深川鼠(ふかがわねずみ)","紺桔梗(こんききょう)","灰青(はいあお)",
        "洒落柿(しゃれがき)","小麦色(こむぎいろ)","若緑(わかみどり)","花色(はないろ)","銀鼠(ぎんねず)",
        "赤香(あかこう)","丹色(にいろ)","浅緑(あさみどり)","紺藍(こんあい)","薄鈍(うすにび)",
        "砥粉色(とのこいろ)","黄茶(きちゃ)","薄緑(うすみどり)","紅桔梗(べにききょう)","薄墨色(うすずみいろ)",
        "肉色(にくいろ)","肉桂色(にっけいいろ)","青鈍(あおにび)","桔梗色(ききょういろ)","錫色(すずいろ)",
        "人色(ひといろ)","赤朽葉色(あかくちばいろ)","青磁鼠(せいじねず)","藤納戸(ふじなんど)","素鼠(すねずみ)",
        "丁子色(ちょうじいろ)","黄櫨染(こうろぜん)","薄青(うすあお)","紅掛花色(べにかけはないろ)","鼠色(ねずみいろ)",
        "香色(こういろ)","蒲公英色(たんぽぽいろ)","錆青磁(さびせいじ)","紫苑色(しおんいろ)","源氏鼠(げんじねず)",
        "薄香(うすこう)","黄色(きいろ)","緑青色(ろくしょういろ)","白藤色(しらふじいろ)","灰色(はいいろ)",
        "浅黄(うすき)","中黄(ちゅうき)","千歳緑(ちとせみどり)","藤紫(ふじむらさき)","鉛色(なまりいろ)",
        "枯色(かれいろ)","菜の花色(なのはないろ)","若竹色(わかたけいろ)","菫色(すみれいろ)","鈍色(にびいろ)",
        "淡香(うすこう)","黄檗色(きはだいろ)","緑(みどり)","青紫(あおむらさき)","墨(すみ)",
        "杏色(あんずいろ)","卵色(たまごいろ)","常磐色(ときわいろ)","菖蒲色(しょうぶいろ)","丼鼠(どぶねずみ)",
        "東雲色(しののめいろ)","花葉色(はなばいろ)","千草鼠(ちぐさねず)","竜胆色(りんどういろ)","消炭色(けしずみいろ)",
        "曙色(あけぼのいろ)","刈安色(かりやすいろ)","千草色(ちぐさいろ)","江戸紫(えどむらさき)","藍墨茶(あいすみちゃ)",
        "珊瑚朱色(さんごしゅいろ)","玉蜀黍色(とうもろこしいろ)","青磁色(せいじいろ)","本紫(ほんむらさき)","羊羹色(ようかんいろ)",
        "深支子(こきくちなし)","金糸雀色(かなりあいろ)","青竹色(あおたけいろ)","葡萄色(ぶどういろ)","蝋色(ろういろ)",
        "纁(そひ)","黄支子色(きくちなしいろ)","常磐緑(ときわみどり)","深紫(ふかむらさき)","黒(くろ)",
        "浅緋(うすきひ)","支子色(くちなしいろ)","木賊色(とくさいろ)","紫黒(しこく)","烏羽色(からすばいろ)",
        "真赭(まそほ)","向日葵色(ひまわりいろ)","天鵞絨(びろうど)","紫(むらさき)","鉄黒(てつぐろ)",
        "洗朱(あらいしゅ)","山吹色(やまぶきいろ)","虫襖(むしあお)","薄葡萄(うすぶどう)","濡羽色(ぬればいろ)",
        "遠州茶(えんしゅうちゃ)","鬱金色(うこんいろ)","革色(かわいろ)","紫紺(しこん)","黒檀(こくたん)",
        "紅樺色(べにかばいろ)","藤黄(とうおう)","深緑(ふかみどり)","暗紅色(あんこうしょく)","憲法黒茶(けんぽうくろちゃ)",
        "赭(そほ)","金色(こんじき)","鉄色(てついろ)","桑の実色(くわのみいろ)","暗黒色(あんこくしょく)",
    ]

    RARE_COLOR = [
        "淡褐色(たんかっしょく)", "白銀色(はくぎんしょく)"
    ]

    NORMAL_COLOR = [
        "黒色(こくしょく)"
    ]

    NORMAL_SKIN_COLOR = [
        "桜色(さくらいろ)","薄桜(うすざくら)","桜鼠(さくらねず)","鴇鼠(ときねず)","虹色(にじいろ)",
        "珊瑚色(さんごいろ)","一斤染(いっこんぞめ)","宍色(ししいろ)","紅梅色(こうばいいろ)","薄紅(うすべに)",
        "甚三紅(じんざもみ)","桃色(ももいろ)","鴇色(ときいろ)","撫子色(なでしこいろ)","灰梅(はいうめ)",
        "灰桜(はいざくら)","淡紅藤(あわべにふじ)","石竹色(せきちくいろ)","薄紅梅(うすこうばい)","桃花色(ももはないろ)",
        "水柿(みずがき)","ときがら茶(ときがらちゃ)","退紅(あらぞめ)","薄柿(うすがき)","長春色(ちょうしゅんいろ)",
        "梅鼠(うめねず)","鴇浅葱(ときあさぎ)","梅染(うめぞめ)","蘇芳香(すおうこう)","象牙色(ぞうげいろ)",
        "練色(ねりいろ)","灰白色(かいはくしょく)","鳥の子色(とりのこいろ)","蜂蜜色(はちみついろ)","肌色(はだいろ)",
        "薄卵色(うすたまごいろ)","雄黄(ゆうおう)","洒落柿(しゃれがき)","赤香(あかこう)","砥粉色(とのこいろ)",
        "肉色(にくいろ)","人色(ひといろ)","丁子色(ちょうじいろ)","香色(こういろ)","薄香(うすこう)",
        "浅黄(うすき)","枯色(かれいろ)","淡香(うすこう)","杏色(あんずいろ)","東雲色(しののめいろ)",
        "曙色(あけぼのいろ)","珊瑚朱色(さんごしゅいろ)","深支子(こきくちなし)","纁(そひ)","浅緋(うすきひ)",
        "真赭(まそほ)","洗朱(あらいしゅ)","遠州茶(えんしゅうちゃ)","紅樺色(べにかばいろ)","赭(そほ)",
    ]

    # ストレートコース(年齢-10で参照)
    EDUCATIONAL_BACKGROUND = [
        "小学4年生", "小学5年生", "小学6年生",
        "中学1年生", "中学2年生", "中学3年生",
        "高校1年生", "高校2年生", "高校3年生",
        "大学1年生", "大学2年生", "大学3年生", "大学4年生",
        "大学院修士課程1年", "大学院修士課程2年",
        "大学院博士課程1年", "大学院博士課程2年", "大学院博士課程3年", "大学院博士課程4年", "大学院博士課程5年",
        "大学院専門職学位課程1年", "大学院専門職学位課程2年",
    ]

    def __init__(self):
        self.investigator: Investigator = None

        self.height = ""
        self.weight = ""

        self.body_type = ""
        self.body_type_tag = ""

        self.hair_color = ""
        self.eye_color = ""
        self.skin_color = ""

        self.final_education = ""

        self.appearance_rarity = ""

    def calculate(self, investigator: Investigator):
        self.investigator: Investigator = investigator

        age = int(self.investigator.personal_data.age)

        # ■ SIZ (ルルブP166より抜粋)
        #  8:  50- 55kg
        # 12:  71- 76kg
        # 16: 100-109kg
        # 20: 141-154kg
        # 24: 200-218kg
        # 32: 400-436kg
        # この通りあまり参考にならない。

        # なので、細かく分類分けされているこのサイトを参考にした。
        # https://g12a1.exblog.jp/23619557/

        # 身長
        fluctuation_height = random.choice(CharacterAppearance.FLUCTUATION_HEIGHT_RANGE)
        height_value = CharacterAppearance.SIZ_HEIGHT[self.investigator.SIZ] + fluctuation_height
        self.height = f"{height_value}cm"

        # 体重
        fluctuation_weight = random.choice(CharacterAppearance.FLUCTUATION_WEIGHT_RANGE)
        weight_value = CharacterAppearance.SIZ_WEIGHT[self.investigator.SIZ] + fluctuation_weight
        self.weight = f"{weight_value}kg"

        # SIZ  7 : 女子平均(中2)
        # SIZ  9 : 男子平均(中2)
        # SIZ 10 : 女性平均(日本)
        # SIZ 12 : 男子平均(高校)
        # SIZ 13 : 男性平均(日本)

        # SIZ LL   L      M     S   SS    体重
        #  3:     110    120   135        31kg
        #  4:     115    125   140        34kg
        #  5:     120    130   145        37kg
        #  6:     125    135   150        40kg
        #  7:     130    140   155        43kg

        # STR依存でぽっちゃり系か、ガッチリ系かを決める。
        # LL: 肥満 or ムキムキ
        # L : ポッチャリ or マッチョ
        #   : ふっくら or ガッシリ
        # M : 標準
        #   : ほっそり or スマート
        # S : スレンダー
        # SS: ガリガリ

        #           L     M      S
        # height:  -5     0     +5
        # weight:   5     0     -5

        # STR 3d6   :   3 - 18
        # SIZ 2d6+6 :   8 - 18
        #        -3 :   5 - 15

        # 筋肉量
        # STRがSIZ-3以上なら、筋肉質と判断する。
        muscle = (self.investigator.STR >= self.investigator.SIZ - 3)

        body_type_rarity = ""

        # 体型
        self.body_type = "普通の体型"
        if muscle:
            # 筋肉体型
            if (fluctuation_height <= -4) and (fluctuation_weight >= 4):
                body_type_rarity = "[BT-R]"
                self.body_type = "ムキムキガッシリ体型"
            elif (fluctuation_height >= 4) and (fluctuation_weight <= -4):
                body_type_rarity = "[BT-R]"
                self.body_type = "スレンダー体型"
        else:
            # 肥満体型
            if (fluctuation_height <= -4) and (fluctuation_weight >= 4):
                body_type_rarity = "[BT-R]"
                self.body_type = "ムチムチぽっちゃり体型"
            elif (fluctuation_height >= 4) and (fluctuation_weight <= -4):
                body_type_rarity = "[BT-R]"
                self.body_type = "ガリガリ体型"

        self.body_type_tag = f"h{fluctuation_height}w{fluctuation_weight}"


        hair_color_rarity = ""

        # 髪の色
        self.hair_color = random.choice(CharacterAppearance.NORMAL_COLOR)
        lottery1 = random.randint(1, 100)
        if lottery1 <= 5:
            # クリティカル
            lottery2 = random.randint(1, 100)
            if lottery2 <= 5:
                # クリティカル
                hair_color_rarity = "[HC-SR]"
                self.hair_color = random.choice(CharacterAppearance.SUPER_RARE_COLOR)
            else:
                # レア
                hair_color_rarity = "[HC-R]"
                self.hair_color = random.choice(CharacterAppearance.RARE_COLOR)

        eye_color_rarity = ""

        # 瞳の色
        self.eye_color = random.choice(CharacterAppearance.NORMAL_COLOR)
        lottery1 = random.randint(1, 100)
        if lottery1 <= 5:
            # クリティカル
            lottery2 = random.randint(1, 100)
            if lottery2 <= 5:
                # クリティカル
                eye_color_rarity = "[EC-SR]"
                self.eye_color = random.choice(CharacterAppearance.SUPER_RARE_COLOR)

        # 肌の色
        self.skin_color = random.choice(CharacterAppearance.NORMAL_SKIN_COLOR)


        # 学歴: Educational background
        # EDU 06 中学1年生                AGE 13
        # EDU 07 中学2年生                AGE 14
        # EDU 08 中学3年生                AGE 15
        # EDU 09 高校1年生                AGE 16
        # EDU 10 高校2年生                AGE 17
        # EDU 11 高校3年生                AGE 18
        # EDU 12 大学1年生                AGE 19
        # EDU 13 大学2年生                AGE 20
        # EDU 14 大学3年生                AGE 21
        # EDU 15 大学4年生                AGE 22
        # EDU 16 大学院修士課程1年        AGE 23
        # EDU 17 大学院修士課程2年        AGE 24
        # EDU 18 大学院博士課程1年        AGE 25
        # EDU 19 大学院博士課程2年        AGE 26
        # EDU 20 大学院博士課程3年        AGE 27
        # EDU 21 大学院博士課程4年        AGE 28
        # EDU 22 大学院博士課程5年        AGE 29
        # EDU 23 大学院専門職学位課程1年  AGE 30
        # EDU 24 大学院専門職学位課程2年  AGE 31
        if age >= 32:
            # 立派な大人(大人は学歴はあまり関係ないが)
            if self.investigator.EDU >= 23:
                # 大学院専門職学位課程修了
                self.final_education = "大学院専門職学位課程修了"

            elif self.investigator.EDU >= 18:
                # 大学院博士課程修了
                self.final_education = "大学院博士課程修了"

            elif self.investigator.EDU >= 16:
                # 大学院修士課程修了
                self.final_education = "大学院修士課程修了"

            elif self.investigator.EDU >= 12:
                # 大学卒業
                self.final_education = "大学卒業"
            elif self.investigator.EDU >= 9:
                # 高校卒業
                self.final_education = "高等学校卒業"
            else:
                # 中学卒業
                self.final_education = "中学校卒業"

        elif age >= 30:
            # 大学院専門職学位課程の可能性あり
            if self.investigator.EDU >= 23:
                # 大学院専門職学位課程中★
                self.final_education = CharacterAppearance.EDUCATIONAL_BACKGROUND[age - 10]

            elif self.investigator.EDU >= 18:
                # 大学院博士課程修了
                self.final_education = "大学院博士課程修了"

            elif self.investigator.EDU >= 16:
                # 大学院修士課程修了
                self.final_education = "大学院修士課程修了"

            elif self.investigator.EDU >= 12:
                # 大学卒業
                self.final_education = "大学卒業"

            elif self.investigator.EDU >= 9:
                # 高校卒業
                self.final_education = "高等学校卒業"
            else:
                # 中学卒業
                self.final_education = "中学校卒業"

        elif age >= 25:
            # 大学院博士課程の可能性あり
            if self.investigator.EDU >= 18:
                # 大学院博士課程中★
                self.final_education = CharacterAppearance.EDUCATIONAL_BACKGROUND[age - 10]

            elif self.investigator.EDU >= 16:
                # 大学院修士課程修了
                self.final_education = "大学院修士課程修了"

            elif self.investigator.EDU >= 12:
                # 大学卒業
                self.final_education = "大学卒業"

            elif self.investigator.EDU >= 9:
                # 高校卒業
                self.final_education = "高等学校卒業"
            else:
                # 中学卒業
                self.final_education = "中学校卒業"

        elif age >= 23:
            # 大学院修士課程の可能性あり
            if self.investigator.EDU >= 16:
                # 大学院修士課程中★
                self.final_education = CharacterAppearance.EDUCATIONAL_BACKGROUND[age - 10]

            elif self.investigator.EDU >= 12:
                # 大学卒業
                self.final_education = "大学卒業"

            elif self.investigator.EDU >= 9:
                # 高校卒業
                self.final_education = "高等学校卒業"
            else:
                # 中学卒業
                self.final_education = "中学校卒業"

        elif age >= 19:
            # 大学生の可能性あり
            if self.investigator.EDU >= 12:
                # 大学在学中★
                self.final_education = CharacterAppearance.EDUCATIONAL_BACKGROUND[age - 10]

            elif self.investigator.EDU >= 9:
                # 高校卒業
                self.final_education = "高等学校卒業"
            else:
                # 中学卒業
                self.final_education = "中学校卒業"

        elif age >= 16:
            # 高校生の可能性あり
            if self.investigator.EDU >= 9:
                # 高校在学中★
                self.final_education = CharacterAppearance.EDUCATIONAL_BACKGROUND[age - 10]
            else:
                # 中学卒業
                self.final_education = "中学校卒業"

        elif age >= 13:
            # 中学生の可能性あり
            self.final_education = CharacterAppearance.EDUCATIONAL_BACKGROUND[age - 10]
        else:
            # 小学生
            self.final_education = CharacterAppearance.EDUCATIONAL_BACKGROUND[age - 10]

        # レア記録
        self.appearance_rarity = f"{body_type_rarity}{hair_color_rarity}{eye_color_rarity}"
