init
This commit is contained in:
commit
b887f15662
21 changed files with 1038 additions and 0 deletions
63
include/SwordLogic.h
Normal file
63
include/SwordLogic.h
Normal file
|
|
@ -0,0 +1,63 @@
|
|||
#pragma once
|
||||
|
||||
#include "Packet.h"
|
||||
#include <cstdint>
|
||||
#include <random>
|
||||
|
||||
class SwordLogic {
|
||||
public:
|
||||
// 강화 비용 계산
|
||||
static uint64_t GetUpgradeCost(uint32_t currentLevel) {
|
||||
// 0강은 무료
|
||||
if (currentLevel == 0)
|
||||
return 0;
|
||||
// 레벨이 오를수록 비용 증가
|
||||
return (currentLevel * 1000) + 500;
|
||||
}
|
||||
|
||||
// 판매 가격 계산
|
||||
static uint64_t GetSellPrice(uint32_t currentLevel) {
|
||||
if (currentLevel == 0)
|
||||
return 100;
|
||||
// 성공 횟수에 비례하여 상승
|
||||
return (currentLevel * 2000) + 1000;
|
||||
}
|
||||
|
||||
// 강화 시도 결과 계산 (0: 파괴, 1: 성공, 2: 실패)
|
||||
static uint8_t TryUpgrade(uint32_t currentLevel) {
|
||||
// 최대 레벨 도달 시 실패 처리
|
||||
if (currentLevel >= GameConfig::MAX_SWORD_LEVEL)
|
||||
return 2;
|
||||
|
||||
static std::random_device rd;
|
||||
static std::mt19937 gen(rd());
|
||||
std::uniform_int_distribution<int> dis(1, 100);
|
||||
int randVal = dis(gen);
|
||||
|
||||
// 확률 설정
|
||||
int successProb = 0;
|
||||
int destroyProb = 0;
|
||||
|
||||
if (currentLevel < 10) {
|
||||
// 0~9강: 성공 확률 높음, 파괴 없음
|
||||
// 90% ~ 45%
|
||||
successProb = 90 - (currentLevel * 5);
|
||||
destroyProb = 0;
|
||||
} else {
|
||||
// 10~19강: 성공 확률 낮음, 파괴 존재
|
||||
// 40% ~ 4%
|
||||
successProb = 40 - ((currentLevel - 10) * 4);
|
||||
// 5% ~ 23%
|
||||
destroyProb = 5 + ((currentLevel - 10) * 2);
|
||||
}
|
||||
|
||||
// 성공
|
||||
if (randVal <= successProb)
|
||||
return 1;
|
||||
// 파괴
|
||||
if (randVal <= (successProb + destroyProb))
|
||||
return 0;
|
||||
// 실패
|
||||
return 2;
|
||||
}
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue