Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Design for version 2.0. #44

Open
thananon opened this issue Mar 31, 2021 · 1 comment
Open

Design for version 2.0. #44

thananon opened this issue Mar 31, 2021 · 1 comment
Labels
help wanted Extra attention is needed

Comments

@thananon
Copy link
Owner

โปรเจ็คโตแบบออร์แกนิคเกินไปทำให้โค้ดตอนนี้มั่วมาก ตอนนี้หงุดหงิดกับการแก้โค้ดมากๆ มันเริ่มใหญ่และพันกันยุ่งเหยิงไปหมด ต้องตัดไฟแต่ต้นลม ขอแนะนำ twitch tool 2.0 ที่ไม่มี feature เพิ่ม แต่ refactor เพื่อสุขภาพจิต

Design

แยกเป็น module ชัดเจน

  1. twitch_front -> twitch event handler (จัดการทั่วไป เช่นการ timeout/ตอบคำถาม)
  2. discord_front -> discord event handler (จัดการทั่วไป)
  3. db_service -> คุมการอ่าน/เขียน db
  4. bot_service -> บริการต่างๆของ bot ที่ต้องติดต่อกับ player_db เช่น gacha/auction
  5. webapp -> เราไม่แตะต้องเพราะมันดีอยู่แล้ว
                      webapp
                    /
twitch -> twitch_front ---------------------
                  |          \              \
                  |           bot_service - > db_service
                  |          /
discord -> discord_front ->
  • twitch_front มีความจำเป็นต้องติดต่อกับ db เพราะเราเก็บ twitch user เป็นหลัก (update userlist/ดึง list online users)
  • twitch_front ต้องส่ง message เข้า discord channel เราได้ด้วย (แสดงผลผู้ชนะกาชา/ประมูล)
  • discord_front ตอนนี้ยังไม่มีความจำเป็นต้องติดต่อกับ db เพราะเรายังใช้ twitch username เป็นหลัก และยังไม่มีวิธีดีๆที่จะ link discord username->twitch username เลยออกแบบให้เป็น read-only แต่ใจจริงๆอยากให้มา gacha กันใน discord ได้ด้วย แค่ยังคิดไม่ออกจะทำไงดี (แยก user/wallet ไปเลยมั้ย)
  • bot_service และ db_service ควรเป็น daemon ที่ตัว front ต้องมา connect ก่อน ถ้าสองตัวนี้ไม่อยู่ก็ให้ front ตายไปเลย
  • db_service เราจะใช้ db จริงๆหรือ JSON ยังไหวอยู่?
  • Priority คือ bot/db service เราทำให้เสร็จก่อนแล้วค่อยทำ front ทีหลัง
  • typescript?

bot_service methods

ดีไซน์คร่าวๆ สิ่งที่อยากให้มี จะมา edit เพิ่มเรื่อยๆ

## High level events
- gacha
- auction
  - auction start/end
  - bid (username, amount)
- raffles
  - raffle start/end
  - raffle_join(username, total)

## bot character parameters
- atk_power
- level
- critrate
- etc

db_service methods

- getPlayerbyUsername
- createPlayer
- removePlayer
- sync/save/load

## coin manipulations
- deduct_coin (username, amount)
- give_coin (username, amount)
- give_coin_to_all_online(amount)
- get_total_coin (username)
- get_top_coin(total)
@thananon thananon added the help wanted Extra attention is needed label Mar 31, 2021
This was referenced Mar 31, 2021
@thananon
Copy link
Owner Author

ใช้ branch v2.0.0 เป็น staging นะครับ

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

1 participant