Skip to content

Commit

Permalink
lint対応
Browse files Browse the repository at this point in the history
  • Loading branch information
fono09 committed Mar 6, 2022
1 parent aad97a6 commit f7f4c9b
Showing 1 changed file with 52 additions and 17 deletions.
69 changes: 52 additions & 17 deletions library/omikuji.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,22 @@
おみくじを返す
"""

from abc import ABC
from enum import Enum, auto
from dataclasses import dataclass
from functools import reduce
from random import choices
from typing import TypeVar, Generic


TOmikujiEnum = TypeVar('TOmikujiEnum')

TOmikujiEnum = TypeVar('TOmikujiEnum') # type: ignore

@dataclass
class OmikujiResult:
"""
おみくじの引いた結果を示すデータクラス
排出率の調整もここで行う
"""
key: TOmikujiEnum
rate: float
message: str
Expand Down Expand Up @@ -55,31 +58,63 @@ def draw(self) -> OmikujiResult:
"""
return choices(
population=list(self.entries.items()),
weights=map(lambda entry: entry.rate, self.entries.values()),
weights=list(map(lambda entry: entry.rate, self.entries.values())),
k=1
)[0][1]


# 以下おみくじの設定

class OmikujiResults(Enum):
DaiKichi = auto()
ChuKichi = auto()
ShoKichi = auto()
HatoKichi = auto()
Kichi = auto()
Kyo = auto()
DaiKyo = auto()
DAI_KICHI = auto()
CHU_KICHI = auto()
SHO_KICHI = auto()
HATO_KICHI = auto()
KICHI = auto()
KYO = auto()
DAI_KYO = auto()


omikuji = Omikuji[OmikujiResults](entries={
OmikujiResults.DaiKichi: OmikujiResult(OmikujiResults.DaiKichi, 0.02, ":tada: 大吉 何でもうまくいく!!気がする!!"),
OmikujiResults.ChuKichi: OmikujiResult(OmikujiResults.ChuKichi, 0.2, ":smile: 中吉 そこそこうまくいくかも!?"),
OmikujiResults.ShoKichi: OmikujiResult(OmikujiResults.ShoKichi, 0.38, ":smily: 小吉 なんとなくうまくいくかも!?"),
OmikujiResults.Kichi: OmikujiResult(OmikujiResults.Kichi, 0.3, ":smirk: 吉 まあうまくいくかも!?"),
OmikujiResults.HatoKichi: OmikujiResult(OmikujiResults.HatoKichi, 0.09, ":dove_of_peace: 鳩吉 お前がになる番だ!!羽ばたけ!!!飛べ!!!!唐揚げになれ!!!!!"),
OmikujiResults.Kyo: OmikujiResult(OmikujiResults.Kyo, 0.0075, ":cry: 凶 ちょっと慎重にいったほうがいいかも……"),
OmikujiResults.DaiKyo: OmikujiResult(OmikujiResults.DaiKyo, 0.0025, ":crying_cat_face: 大凶 そういう時もあります……猫になって耐えましょう"),
OmikujiResults.DAI_KICHI: OmikujiResult(
OmikujiResults.DAI_KICHI,
0.02,
":tada: 大吉 何でもうまくいく!!気がする!!"
),
OmikujiResults.CHU_KICHI: OmikujiResult(
OmikujiResults.CHU_KICHI,
0.2,
":smile: 中吉 そこそこうまくいくかも!?"
),
OmikujiResults.SHO_KICHI: OmikujiResult(
OmikujiResults.SHO_KICHI,
0.38,
":smily: 小吉 なんとなくうまくいくかも!?"
),

OmikujiResults.KICHI: OmikujiResult(
OmikujiResults.KICHI,
0.3,
":smirk: 吉 まあうまくいくかも!?"
),
OmikujiResults.HATO_KICHI: OmikujiResult(
OmikujiResults.HATO_KICHI,
0.09,
":dove_of_peace: 鳩吉 お前がになる番だ!!羽ばたけ!!!飛べ!!!!唐揚げになれ!!!!!"
),

OmikujiResults.KYO: OmikujiResult(
OmikujiResults.KYO,
0.0075,
":cry: 凶 ちょっと慎重にいったほうがいいかも……"
),

OmikujiResults.DAI_KYO: OmikujiResult(
OmikujiResults.DAI_KYO,
0.0025,
":crying_cat_face: 大凶 そういう時もあります……猫になって耐えましょう"
),

})


Expand Down

0 comments on commit f7f4c9b

Please sign in to comment.