コード例 #1
0
ファイル: EvolutionScreen.cpp プロジェクト: Lin20/projectpmr
void EvolutionScreen::HitB()
{
	if (main_frame->GetTextboxes().size() == 0)
		main_frame->CancelClose();
	if (color_timer)
		return;
	if (frames == 1 || delay == 255)
		return;

	color_timer = 255;
	frames = 1;
	Textbox* frame = main_frame;
	Textbox* canceled = new Textbox();
	canceled->SetText(new TextItem(canceled, [frame](TextItem* src) {frame->Close(true); }, pokestring("Huh? ").append(pokemon->nickname).append(pokestring("\nstopped evolving!\f"))));
	main_frame->ShowTextbox(canceled, false);
}
コード例 #2
0
ファイル: EvolutionScreen.cpp プロジェクト: Lin20/projectpmr
void EvolutionScreen::Finalize()
{
	Textbox* main_frame = this->main_frame;
	Textbox* evolved = new Textbox();

	bool learned_move = false;
	std::function<void(TextItem* s)> m_f = nullptr;
	for (int i = 0; i < 16; i++)
	{
		if (pokemon_to->learnset[i].level == 0)
			break;
		if (pokemon_to->learnset[i].level == pokemon->level)
		{
			m_f = PokemonUtils::LearnMove(evolved, pokemon, pokemon_to->learnset[i].move);
			learned_move = true;
		}
	}

	std::function<void(TextItem* s)> a = [m_f, evolved](TextItem* src) {
		evolved->CancelClose(); 
		m_f(src); 
	};
	evolved->SetText(new TextItem(evolved, (!m_f ? [main_frame, evolved](TextItem* src) {evolved->Close(); main_frame->Close(); } : a), string(pokemon->nickname).append(pokestring(" evolved\ninto ")).append(pokemon_to->original_name).append(pokestring("!\t\t\t\t\t\t\a"))));
	main_frame->ShowTextbox(evolved, false);
	if (learned_move)
	{
		auto b = [evolved, main_frame, this](TextItem* s)
		{
			evolved->Close(true);
			main_frame->Close();
			this->parent->Close();
		};
		evolved->SetCloseCallback(b);
	}

	pokemon->id = pokemon_to->id;
	pokemon->pokedex_index = pokemon_to->pokedex_index;
	pokemon->LoadStats();
	unsigned int hp = pokemon->max_hp;
	pokemon->RecalculateStats();
	pokemon->hp += pokemon->max_hp - hp;
}