C++でポケモンのステータスを計算する

ポケモンのステータスを計算する方法はここを参照

Just a moment...

これをC++で計算する。レベルと種族値、個体値、努力値を指定すれば計算できる。種族値例はツタージャ。

結果

231,126,146,126,146,162

コード

#include <iostream>
#include <array>

class kPokemon {
public:
	kPokemon() {}
	~kPokemon() {}
	void setLV(int LV) {
		m_LV = LV;
	}
	void setBSs(std::array<char, 6> BSs) {
		m_BSs = BSs;
	}
	void setIVs(std::array<char, 6> IVs) {
		m_IVs = IVs;
	}
	void setEVs(std::array<char, 6> EVs) {
		m_EVs = EVs;
	}
	void getStatus() {
		m_H = ((double)m_BSs[0] * 2 + (double)m_IVs[0] + (double)m_EVs[0] / 4) * (double)m_LV / 100 + (double)m_LV + 10;
		m_A = (((double)m_BSs[1] * 2 + (double)m_IVs[1] + (double)m_EVs[1] / 4) * (double)m_LV / 100 + 5) * m_Nature;
		m_B = (((double)m_BSs[2] * 2 + (double)m_IVs[2] + (double)m_EVs[2] / 4) * (double)m_LV / 100 + 5) * m_Nature;
		m_C = (((double)m_BSs[3] * 2 + (double)m_IVs[3] + (double)m_EVs[3] / 4) * (double)m_LV / 100 + 5) * m_Nature;
		m_D = (((double)m_BSs[4] * 2 + (double)m_IVs[4] + (double)m_EVs[4] / 4) * (double)m_LV / 100 + 5) * m_Nature;
		m_S = (((double)m_BSs[5] * 2 + (double)m_IVs[5] + (double)m_EVs[5] / 4) * (double)m_LV / 100 + 5) * m_Nature;

		std::cout << m_H << "," << m_A << "," << m_B << "," << m_C << "," << m_D << "," << m_S << std::endl;
	}
private:
	std::array<char, 6> m_BSs = { 0,0,0,0,0,0 };
	std::array<char, 6> m_IVs = { 0,0,0,0,0,0 };
	std::array<char, 6> m_EVs = { 0,0,0,0,0,0 };

	int m_LV = 0;
	int m_H = 0, m_A = 0, m_B = 0, m_C = 0, m_D = 0, m_S = 0;
	int m_Nature = 1;

};
int main() {
	kPokemon snivy;
	int LV = 100;
	std::array<char, 6> BSs = { 45,45,55,45,55,63 };
	std::array<char, 6> IVs = { 31,31,31,31,31,31 };
	std::array<char, 6> EVs = { 0,0,0,0,0,0 };

	snivy.setBSs(BSs);
	snivy.setIVs(IVs);
	snivy.setEVs(EVs);
	snivy.setLV(LV);

	snivy.getStatus();

	return 0;
}

コメント

タイトルとURLをコピーしました