Fixes Pokemon::get_Nickname in angelscript.
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/push Build is passing
Details
This commit is contained in:
parent
728bc13ac1
commit
3a5fa268dd
|
@ -159,4 +159,10 @@ namespace PkmnLib::Battling {
|
||||||
_allowedExperienceGain = value;
|
_allowedExperienceGain = value;
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CreatePokemon& CreatePokemon::WithNickname(const std::string& nickname) {
|
||||||
|
_nickname = nickname;
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -9,7 +9,7 @@ namespace PkmnLib::Battling {
|
||||||
ArbUt::StringView _species = ""_cnc;
|
ArbUt::StringView _species = ""_cnc;
|
||||||
ArbUt::StringView _forme = "default"_cnc;
|
ArbUt::StringView _forme = "default"_cnc;
|
||||||
level_int_t _level;
|
level_int_t _level;
|
||||||
std::string _nickname = "";
|
std::optional<std::string> _nickname = "";
|
||||||
|
|
||||||
ArbUt::StringView _ability = ""_cnc;
|
ArbUt::StringView _ability = ""_cnc;
|
||||||
ArbUt::StringView _nature;
|
ArbUt::StringView _nature;
|
||||||
|
@ -66,6 +66,8 @@ namespace PkmnLib::Battling {
|
||||||
|
|
||||||
CreatePokemon& WithNature(const ArbUt::StringView& nature);
|
CreatePokemon& WithNature(const ArbUt::StringView& nature);
|
||||||
CreatePokemon& IsAllowedExperienceGain(bool value);
|
CreatePokemon& IsAllowedExperienceGain(bool value);
|
||||||
|
CreatePokemon& WithNickname(const std::string& nickname);
|
||||||
|
|
||||||
|
|
||||||
Pokemon* Build() {
|
Pokemon* Build() {
|
||||||
auto rand = ArbUt::Random();
|
auto rand = ArbUt::Random();
|
||||||
|
|
|
@ -143,7 +143,7 @@ void RegisterPokemonClass::RegisterPokemonType(asIScriptEngine* engine) {
|
||||||
r = engine->RegisterObjectMethod("Pokemon", "uint32 get_CurrentHealth() const property",
|
r = engine->RegisterObjectMethod("Pokemon", "uint32 get_CurrentHealth() const property",
|
||||||
asMETHOD(PkmnLib::Battling::Pokemon, GetCurrentHealth), asCALL_THISCALL);
|
asMETHOD(PkmnLib::Battling::Pokemon, GetCurrentHealth), asCALL_THISCALL);
|
||||||
Ensure(r >= 0);
|
Ensure(r >= 0);
|
||||||
r = engine->RegisterObjectMethod("Pokemon", "const string& get_Nickname() const property",
|
r = engine->RegisterObjectMethod("Pokemon", "string get_Nickname() const property",
|
||||||
asFUNCTION(NicknameWrapper), asCALL_CDECL_OBJFIRST);
|
asFUNCTION(NicknameWrapper), asCALL_CDECL_OBJFIRST);
|
||||||
Ensure(r >= 0);
|
Ensure(r >= 0);
|
||||||
r = engine->RegisterObjectMethod("Pokemon", "const constString& get_ActiveAbility() const property",
|
r = engine->RegisterObjectMethod("Pokemon", "const constString& get_ActiveAbility() const property",
|
||||||
|
|
|
@ -187,20 +187,21 @@ TEST_CASE("Validate Pokemon CurrentHealth in Script") {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_CASE("Validate Pokemon Nickname in Script") {
|
TEST_CASE("Validate Pokemon Nickname in Script") {
|
||||||
// auto mainLib = TestLibrary::GetLibrary();
|
auto mainLib = TestLibrary::GetLibrary();
|
||||||
// auto data = GetScript(mainLib, "testNickname"_cnc);
|
auto data = GetScript(mainLib, "testNickname"_cnc);
|
||||||
//
|
|
||||||
// auto mon = PkmnLib::Battling::CreatePokemon(mainLib, "testSpecies"_cnc, 30)
|
auto mon = PkmnLib::Battling::CreatePokemon(mainLib, "testSpecies"_cnc, 30)
|
||||||
// .WithForme("default"_cnc)
|
.WithForme("default"_cnc)
|
||||||
// .WithGender(CreatureLib::Library::Gender::Male)
|
.WithGender(CreatureLib::Library::Gender::Male)
|
||||||
// .Build();
|
.WithNickname("foobar")
|
||||||
// data.Context->SetArgObject(0, (void*)mon);
|
.Build();
|
||||||
// auto name = std::string(mon->GetNickname());
|
data.Context->SetArgObject(0, (void*)mon);
|
||||||
// data.Context->SetArgAddress(1, &name);
|
auto name = std::string(mon->GetNickname().value());
|
||||||
//
|
data.Context->SetArgAddress(1, &name);
|
||||||
// REQUIRE(data.Context->Execute() == asEXECUTION_FINISHED);
|
|
||||||
// REQUIRE((bool)data.Context->GetReturnWord());
|
REQUIRE(data.Context->Execute() == asEXECUTION_FINISHED);
|
||||||
// delete mon;
|
REQUIRE((bool)data.Context->GetReturnWord());
|
||||||
|
delete mon;
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_CASE("Validate Pokemon Active Ability in Script") {
|
TEST_CASE("Validate Pokemon Active Ability in Script") {
|
||||||
|
|
Loading…
Reference in New Issue