From 3e6c5243b09d87acd4c89f140d3fedbfa88b8fd8 Mon Sep 17 00:00:00 2001 From: DragonAura Date: Fri, 12 May 2023 20:38:54 +0800 Subject: [PATCH] feat: :sparkles: add some updates --- CAPI/cpp/API/include/API.h | 12 ++-- CAPI/cpp/API/include/Communication.h | 2 +- CAPI/cpp/API/include/logic.h | 2 +- CAPI/cpp/API/include/structures.h | 6 +- CAPI/cpp/API/include/utils.hpp | 7 ++- CAPI/cpp/API/src/API.cpp | 8 +-- CAPI/cpp/API/src/Communication.cpp | 4 +- CAPI/cpp/API/src/DebugAPI.cpp | 12 ++-- CAPI/cpp/API/src/logic.cpp | 4 +- CAPI/cpp/proto/Message2Server.pb.cc | 48 ++++++++++++---- CAPI/cpp/proto/Message2Server.pb.h | 36 ++++++++++++ CAPI/cpp/proto/MessageType.pb.cc | 79 ++++++++++++++------------- CAPI/cpp/proto/MessageType.pb.h | 7 ++- CAPI/python/PyAPI/API.py | 8 +-- CAPI/python/PyAPI/Communication.py | 4 +- CAPI/python/PyAPI/DebugAPI.py | 12 ++-- CAPI/python/PyAPI/Interface.py | 4 +- CAPI/python/PyAPI/logic.py | 4 +- CAPI/python/PyAPI/structures.py | 3 +- CAPI/python/PyAPI/utils.py | 12 +++- dependency/proto/Message2Server.proto | 1 + dependency/proto/MessageType.proto | 7 ++- 22 files changed, 181 insertions(+), 101 deletions(-) diff --git a/CAPI/cpp/API/include/API.h b/CAPI/cpp/API/include/API.h index 81d73ed..0c67986 100644 --- a/CAPI/cpp/API/include/API.h +++ b/CAPI/cpp/API/include/API.h @@ -60,7 +60,7 @@ public: virtual bool PickProp(THUAI6::PropType prop) = 0; virtual bool UseProp(THUAI6::PropType prop) = 0; virtual bool ThrowProp(THUAI6::PropType prop) = 0; - virtual bool UseSkill(int32_t skillID) = 0; + virtual bool UseSkill(int32_t skillID, int32_t skillParam) = 0; virtual bool SendMessage(int64_t toID, std::string message, bool binary) = 0; virtual bool HaveMessage() = 0; virtual std::pair GetMessage() = 0; @@ -108,7 +108,7 @@ public: virtual std::future PickProp(THUAI6::PropType prop) = 0; virtual std::future UseProp(THUAI6::PropType prop) = 0; virtual std::future ThrowProp(THUAI6::PropType prop) = 0; - virtual std::future UseSkill(int32_t skillID) = 0; + virtual std::future UseSkill(int32_t skillID, int32_t skillParam = 0) = 0; virtual std::future Attack(double angleInRadian) = 0; virtual std::future OpenDoor() = 0; @@ -236,7 +236,7 @@ public: std::future PickProp(THUAI6::PropType prop) override; std::future UseProp(THUAI6::PropType prop) override; std::future ThrowProp(THUAI6::PropType prop) override; - std::future UseSkill(int32_t skillID) override; + std::future UseSkill(int32_t skillID, int32_t skillParam = 0) override; std::future Attack(double angleInRadian) override; @@ -329,7 +329,7 @@ public: std::future PickProp(THUAI6::PropType prop) override; std::future UseProp(THUAI6::PropType prop) override; std::future ThrowProp(THUAI6::PropType prop) override; - std::future UseSkill(int32_t skillID) override; + std::future UseSkill(int32_t skillID, int32_t skillParam = 0) override; std::future OpenDoor() override; std::future CloseDoor() override; @@ -410,7 +410,7 @@ public: std::future PickProp(THUAI6::PropType prop) override; std::future UseProp(THUAI6::PropType prop) override; std::future ThrowProp(THUAI6::PropType prop) override; - std::future UseSkill(int32_t skillID) override; + std::future UseSkill(int32_t skillID, int32_t skillParam = 0) override; std::future Attack(double angleInRadian) override; @@ -488,7 +488,7 @@ public: std::future PickProp(THUAI6::PropType prop) override; std::future UseProp(THUAI6::PropType prop) override; std::future ThrowProp(THUAI6::PropType prop) override; - std::future UseSkill(int32_t skillID) override; + std::future UseSkill(int32_t skillID, int32_t skillParam = 0) override; std::future OpenDoor() override; std::future CloseDoor() override; diff --git a/CAPI/cpp/API/include/Communication.h b/CAPI/cpp/API/include/Communication.h index 582a5dc..8415c34 100644 --- a/CAPI/cpp/API/include/Communication.h +++ b/CAPI/cpp/API/include/Communication.h @@ -31,7 +31,7 @@ public: bool PickProp(THUAI6::PropType prop, int64_t playerID); bool UseProp(THUAI6::PropType prop, int64_t playerID); bool ThrowProp(THUAI6::PropType prop, int64_t playerID); - bool UseSkill(int32_t skillID, int64_t playerID); + bool UseSkill(int32_t skillID, int32_t skillParam, int64_t playerID); bool SendMessage(int64_t toID, std::string message, bool binary, int64_t playerID); bool OpenDoor(int64_t playerID); bool CloseDoor(int64_t playerID); diff --git a/CAPI/cpp/API/include/logic.h b/CAPI/cpp/API/include/logic.h index 686b3dc..a9a83c0 100644 --- a/CAPI/cpp/API/include/logic.h +++ b/CAPI/cpp/API/include/logic.h @@ -116,7 +116,7 @@ private: bool PickProp(THUAI6::PropType prop) override; bool UseProp(THUAI6::PropType prop) override; bool ThrowProp(THUAI6::PropType prop) override; - bool UseSkill(int32_t skillID) override; + bool UseSkill(int32_t skillID, int32_t skillParam) override; bool SendMessage(int64_t toID, std::string message, bool binary) override; bool HaveMessage() override; diff --git a/CAPI/cpp/API/include/structures.h b/CAPI/cpp/API/include/structures.h index ca01de0..a777202 100644 --- a/CAPI/cpp/API/include/structures.h +++ b/CAPI/cpp/API/include/structures.h @@ -62,6 +62,7 @@ namespace THUAI6 AddHpOrAp = 6, ShieldOrSpear = 7, RecoveryFromDizziness = 8, + CraftingBench = 9, }; enum class BulletType : unsigned char @@ -71,7 +72,7 @@ namespace THUAI6 CommonAttackOfTricker = 2, BombBomb = 3, JumpyDumpty = 4, - AtomBomb = 5, + Strike = 5, }; // 玩家类型 @@ -363,6 +364,7 @@ namespace THUAI6 {PropType::AddHpOrAp, "AddHpOrAp"}, {PropType::ShieldOrSpear, "ShieldOrSpear"}, {PropType::RecoveryFromDizziness, "RecoveryFromDizziness"}, + {PropType::CraftingBench, "CraftingBench"}, }; @@ -372,7 +374,7 @@ namespace THUAI6 {BulletType::CommonAttackOfTricker, "CommonAttackOfTricker"}, {BulletType::BombBomb, "BombBomb"}, {BulletType::JumpyDumpty, "JumpyDumpty"}, - {BulletType::AtomBomb, "AtomBomb"}, + {BulletType::Strike, "Strike"}, }; inline std::map studentBuffDict{ diff --git a/CAPI/cpp/API/include/utils.hpp b/CAPI/cpp/API/include/utils.hpp index 2575ae2..eefa957 100644 --- a/CAPI/cpp/API/include/utils.hpp +++ b/CAPI/cpp/API/include/utils.hpp @@ -108,6 +108,7 @@ namespace Proto2THUAI6 {protobuf::PropType::ADD_LIFE_OR_CLAIRAUDIENCE, THUAI6::PropType::AddLifeOrClairaudience}, {protobuf::PropType::SHIELD_OR_SPEAR, THUAI6::PropType::ShieldOrSpear}, {protobuf::PropType::RECOVERY_FROM_DIZZINESS, THUAI6::PropType::RecoveryFromDizziness}, + {protobuf::PropType::CRAFTING_BENCH, THUAI6::PropType::CraftingBench}, }; inline std::map playerTypeDict{ @@ -186,7 +187,7 @@ namespace Proto2THUAI6 {protobuf::BulletType::COMMON_ATTACK_OF_TRICKER, THUAI6::BulletType::CommonAttackOfTricker}, {protobuf::BulletType::BOMB_BOMB, THUAI6::BulletType::BombBomb}, {protobuf::BulletType::JUMPY_DUMPTY, THUAI6::BulletType::JumpyDumpty}, - {protobuf::BulletType::ATOM_BOMB, THUAI6::BulletType::AtomBomb}, + {protobuf::BulletType::STRIKE, THUAI6::BulletType::Strike}, }; inline std::map messageOfObjDict{ @@ -373,6 +374,7 @@ namespace THUAI62Proto {THUAI6::PropType::AddLifeOrClairaudience, protobuf::PropType::ADD_LIFE_OR_CLAIRAUDIENCE}, {THUAI6::PropType::AddSpeed, protobuf::PropType::ADD_SPEED}, {THUAI6::PropType::ShieldOrSpear, protobuf::PropType::SHIELD_OR_SPEAR}, + {THUAI6::PropType::CraftingBench, protobuf::PropType::CRAFTING_BENCH}, }; inline std::map playerTypeDict{ @@ -486,11 +488,12 @@ namespace THUAI62Proto return attackMsg; } - inline protobuf::SkillMsg THUAI62ProtobufSkill(int32_t skillID, int64_t id) + inline protobuf::SkillMsg THUAI62ProtobufSkill(int32_t skillID, int32_t skillParam, int64_t id) { protobuf::SkillMsg skillMsg; skillMsg.set_skill_id(skillID); skillMsg.set_player_id(id); + skillMsg.set_skill_param(skillParam); return skillMsg; } } // namespace THUAI62Proto diff --git a/CAPI/cpp/API/src/API.cpp b/CAPI/cpp/API/src/API.cpp index 49138a6..85590a6 100644 --- a/CAPI/cpp/API/src/API.cpp +++ b/CAPI/cpp/API/src/API.cpp @@ -106,16 +106,16 @@ std::future TrickerAPI::ThrowProp(THUAI6::PropType prop) { return logic.ThrowProp(prop); }); } -std::future StudentAPI::UseSkill(int32_t skillID) +std::future StudentAPI::UseSkill(int32_t skillID, int32_t skillParam) { return std::async(std::launch::async, [=]() - { return logic.UseSkill(skillID); }); + { return logic.UseSkill(skillID, skillParam); }); } -std::future TrickerAPI::UseSkill(int32_t skillID) +std::future TrickerAPI::UseSkill(int32_t skillID, int32_t skillParam) { return std::async(std::launch::async, [=]() - { return logic.UseSkill(skillID); }); + { return logic.UseSkill(skillID, skillParam); }); } std::future StudentAPI::OpenDoor() diff --git a/CAPI/cpp/API/src/Communication.cpp b/CAPI/cpp/API/src/Communication.cpp index e134b17..85577ab 100644 --- a/CAPI/cpp/API/src/Communication.cpp +++ b/CAPI/cpp/API/src/Communication.cpp @@ -91,7 +91,7 @@ bool Communication::ThrowProp(THUAI6::PropType prop, int64_t playerID) return false; } -bool Communication::UseSkill(int32_t skillID, int64_t playerID) +bool Communication::UseSkill(int32_t skillID, int32_t skillParam, int64_t playerID) { { std::lock_guard lock(mtxLimit); @@ -101,7 +101,7 @@ bool Communication::UseSkill(int32_t skillID, int64_t playerID) } protobuf::BoolRes useSkillResult; ClientContext context; - auto request = THUAI62Proto::THUAI62ProtobufSkill(skillID, playerID); + auto request = THUAI62Proto::THUAI62ProtobufSkill(skillID, skillParam, playerID); auto status = THUAI6Stub->UseSkill(&context, request, &useSkillResult); if (status.ok()) return useSkillResult.act_success(); diff --git a/CAPI/cpp/API/src/DebugAPI.cpp b/CAPI/cpp/API/src/DebugAPI.cpp index f892cfa..7be6e5a 100644 --- a/CAPI/cpp/API/src/DebugAPI.cpp +++ b/CAPI/cpp/API/src/DebugAPI.cpp @@ -212,21 +212,21 @@ std::future TrickerDebugAPI::ThrowProp(THUAI6::PropType prop) return result; }); } -std::future StudentDebugAPI::UseSkill(int32_t skillID) +std::future StudentDebugAPI::UseSkill(int32_t skillID, int32_t skillParam) { - logger->info("UseSkill: skillID={}, called at {}ms", skillID, Time::TimeSinceStart(startPoint)); + logger->info("UseSkill: skillID={}, skillParam={}, called at {}ms", skillID, skillParam, Time::TimeSinceStart(startPoint)); return std::async(std::launch::async, [=]() - { auto result = logic.UseSkill(skillID); + { auto result = logic.UseSkill(skillID, skillParam); if (!result) logger->warn("UseSkill: failed at {}ms", Time::TimeSinceStart(startPoint)); return result; }); } -std::future TrickerDebugAPI::UseSkill(int32_t skillID) +std::future TrickerDebugAPI::UseSkill(int32_t skillID, int32_t skillParam) { - logger->info("UseSkill: skillID={}, called at {}ms", skillID, Time::TimeSinceStart(startPoint)); + logger->info("UseSkill: skillID={}, skillParam={}, called at {}ms", skillID, skillParam, Time::TimeSinceStart(startPoint)); return std::async(std::launch::async, [=]() - { auto result = logic.UseSkill(skillID); + { auto result = logic.UseSkill(skillID, skillParam); if (!result) logger->warn("UseSkill: failed at {}ms", Time::TimeSinceStart(startPoint)); return result; }); diff --git a/CAPI/cpp/API/src/logic.cpp b/CAPI/cpp/API/src/logic.cpp index 035a071..831f6d0 100644 --- a/CAPI/cpp/API/src/logic.cpp +++ b/CAPI/cpp/API/src/logic.cpp @@ -208,10 +208,10 @@ bool Logic::ThrowProp(THUAI6::PropType prop) return pComm->ThrowProp(prop, playerID); } -bool Logic::UseSkill(int32_t skill) +bool Logic::UseSkill(int32_t skill, int32_t skillParam) { logger->debug("Called UseSkill"); - return pComm->UseSkill(skill, playerID); + return pComm->UseSkill(skill, skillParam, playerID); } bool Logic::SendMessage(int64_t toID, std::string message, bool binary) diff --git a/CAPI/cpp/proto/Message2Server.pb.cc b/CAPI/cpp/proto/Message2Server.pb.cc index 88f5014..a73be67 100644 --- a/CAPI/cpp/proto/Message2Server.pb.cc +++ b/CAPI/cpp/proto/Message2Server.pb.cc @@ -180,7 +180,7 @@ namespace protobuf ::_pbi::ConstantInitialized ) : _impl_{ - /*decltype(_impl_.player_id_)*/ int64_t{0}, /*decltype(_impl_.skill_id_)*/ 0, /*decltype(_impl_._cached_size_)*/ {}} + /*decltype(_impl_.player_id_)*/ int64_t{0}, /*decltype(_impl_.skill_id_)*/ 0, /*decltype(_impl_.skill_param_)*/ 0, /*decltype(_impl_._cached_size_)*/ {}} { } struct SkillMsgDefaultTypeInternal @@ -274,6 +274,7 @@ const uint32_t TableStruct_Message2Server_2eproto::offsets[] PROTOBUF_SECTION_VA ~0u, // no _inlined_string_donated_ PROTOBUF_FIELD_OFFSET(::protobuf::SkillMsg, _impl_.player_id_), PROTOBUF_FIELD_OFFSET(::protobuf::SkillMsg, _impl_.skill_id_), + PROTOBUF_FIELD_OFFSET(::protobuf::SkillMsg, _impl_.skill_param_), }; static const ::_pbi::MigrationSchema schemas[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = { {0, -1, -1, sizeof(::protobuf::PlayerMsg)}, @@ -313,9 +314,9 @@ const char descriptor_table_protodef_Message2Server_2eproto[] PROTOBUF_SECTION_V "\t\n\007message\"-\n\tAttackMsg\022\021\n\tplayer_id\030\001 \001" "(\003\022\r\n\005angle\030\002 \001(\001\"\032\n\005IDMsg\022\021\n\tplayer_id\030" "\001 \001(\003\"<\n\021TreatAndRescueMsg\022\021\n\tplayer_id\030" - "\001 \001(\003\022\024\n\014to_player_id\030\002 \001(\003\"/\n\010SkillMsg\022" - "\021\n\tplayer_id\030\001 \001(\003\022\020\n\010skill_id\030\002 \001(\005b\006pr" - "oto3"; + "\001 \001(\003\022\024\n\014to_player_id\030\002 \001(\003\"D\n\010SkillMsg\022" + "\021\n\tplayer_id\030\001 \001(\003\022\020\n\010skill_id\030\002 \001(\005\022\023\n\013" + "skill_param\030\003 \001(\005b\006proto3"; static const ::_pbi::DescriptorTable* const descriptor_table_Message2Server_2eproto_deps[1] = { &::descriptor_table_MessageType_2eproto, }; @@ -323,7 +324,7 @@ static ::_pbi::once_flag descriptor_table_Message2Server_2eproto_once; const ::_pbi::DescriptorTable descriptor_table_Message2Server_2eproto = { false, false, - 684, + 705, descriptor_table_protodef_Message2Server_2eproto, "Message2Server.proto", &descriptor_table_Message2Server_2eproto_once, @@ -2341,10 +2342,10 @@ namespace protobuf SkillMsg* const _this = this; (void)_this; new (&_impl_) Impl_{ - decltype(_impl_.player_id_){}, decltype(_impl_.skill_id_){}, /*decltype(_impl_._cached_size_)*/ {}}; + decltype(_impl_.player_id_){}, decltype(_impl_.skill_id_){}, decltype(_impl_.skill_param_){}, /*decltype(_impl_._cached_size_)*/ {}}; _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); - ::memcpy(&_impl_.player_id_, &from._impl_.player_id_, static_cast(reinterpret_cast(&_impl_.skill_id_) - reinterpret_cast(&_impl_.player_id_)) + sizeof(_impl_.skill_id_)); + ::memcpy(&_impl_.player_id_, &from._impl_.player_id_, static_cast(reinterpret_cast(&_impl_.skill_param_) - reinterpret_cast(&_impl_.player_id_)) + sizeof(_impl_.skill_param_)); // @@protoc_insertion_point(copy_constructor:protobuf.SkillMsg) } @@ -2355,7 +2356,7 @@ namespace protobuf (void)arena; (void)is_message_owned; new (&_impl_) Impl_{ - decltype(_impl_.player_id_){int64_t{0}}, decltype(_impl_.skill_id_){0}, /*decltype(_impl_._cached_size_)*/ {}}; + decltype(_impl_.player_id_){int64_t{0}}, decltype(_impl_.skill_id_){0}, decltype(_impl_.skill_param_){0}, /*decltype(_impl_._cached_size_)*/ {}}; } SkillMsg::~SkillMsg() @@ -2386,7 +2387,7 @@ namespace protobuf // Prevent compiler warnings about cached_has_bits being unused (void)cached_has_bits; - ::memset(&_impl_.player_id_, 0, static_cast(reinterpret_cast(&_impl_.skill_id_) - reinterpret_cast(&_impl_.player_id_)) + sizeof(_impl_.skill_id_)); + ::memset(&_impl_.player_id_, 0, static_cast(reinterpret_cast(&_impl_.skill_param_) - reinterpret_cast(&_impl_.player_id_)) + sizeof(_impl_.skill_param_)); _internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); } @@ -2421,6 +2422,16 @@ namespace protobuf else goto handle_unusual; continue; + // int32 skill_param = 3; + case 3: + if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 24)) + { + _impl_.skill_param_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint32(&ptr); + CHK_(ptr); + } + else + goto handle_unusual; + continue; default: goto handle_unusual; } // switch @@ -2469,6 +2480,13 @@ namespace protobuf target = ::_pbi::WireFormatLite::WriteInt32ToArray(2, this->_internal_skill_id(), target); } + // int32 skill_param = 3; + if (this->_internal_skill_param() != 0) + { + target = stream->EnsureSpace(target); + target = ::_pbi::WireFormatLite::WriteInt32ToArray(3, this->_internal_skill_param(), target); + } + if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { target = ::_pbi::WireFormat::InternalSerializeUnknownFieldsToArray( @@ -2500,6 +2518,12 @@ namespace protobuf total_size += ::_pbi::WireFormatLite::Int32SizePlusOne(this->_internal_skill_id()); } + // int32 skill_param = 3; + if (this->_internal_skill_param() != 0) + { + total_size += ::_pbi::WireFormatLite::Int32SizePlusOne(this->_internal_skill_param()); + } + return MaybeComputeUnknownFieldsSize(total_size, &_impl_._cached_size_); } @@ -2528,6 +2552,10 @@ namespace protobuf { _this->_internal_set_skill_id(from._internal_skill_id()); } + if (from._internal_skill_param() != 0) + { + _this->_internal_set_skill_param(from._internal_skill_param()); + } _this->_internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); } @@ -2550,7 +2578,7 @@ namespace protobuf using std::swap; _internal_metadata_.InternalSwap(&other->_internal_metadata_); ::PROTOBUF_NAMESPACE_ID::internal::memswap< - PROTOBUF_FIELD_OFFSET(SkillMsg, _impl_.skill_id_) + sizeof(SkillMsg::_impl_.skill_id_) - PROTOBUF_FIELD_OFFSET(SkillMsg, _impl_.player_id_)>( + PROTOBUF_FIELD_OFFSET(SkillMsg, _impl_.skill_param_) + sizeof(SkillMsg::_impl_.skill_param_) - PROTOBUF_FIELD_OFFSET(SkillMsg, _impl_.player_id_)>( reinterpret_cast(&_impl_.player_id_), reinterpret_cast(&other->_impl_.player_id_) ); diff --git a/CAPI/cpp/proto/Message2Server.pb.h b/CAPI/cpp/proto/Message2Server.pb.h index 7b09cdd..7dd1a64 100644 --- a/CAPI/cpp/proto/Message2Server.pb.h +++ b/CAPI/cpp/proto/Message2Server.pb.h @@ -1813,6 +1813,7 @@ namespace protobuf { kPlayerIdFieldNumber = 1, kSkillIdFieldNumber = 2, + kSkillParamFieldNumber = 3, }; // int64 player_id = 1; void clear_player_id(); @@ -1833,6 +1834,16 @@ namespace protobuf int32_t _internal_skill_id() const; void _internal_set_skill_id(int32_t value); + public: + // int32 skill_param = 3; + void clear_skill_param(); + int32_t skill_param() const; + void set_skill_param(int32_t value); + + private: + int32_t _internal_skill_param() const; + void _internal_set_skill_param(int32_t value); + public: // @@protoc_insertion_point(class_scope:protobuf.SkillMsg) @@ -1847,6 +1858,7 @@ namespace protobuf { int64_t player_id_; int32_t skill_id_; + int32_t skill_param_; mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_; }; union @@ -2597,6 +2609,30 @@ namespace protobuf // @@protoc_insertion_point(field_set:protobuf.SkillMsg.skill_id) } + // int32 skill_param = 3; + inline void SkillMsg::clear_skill_param() + { + _impl_.skill_param_ = 0; + } + inline int32_t SkillMsg::_internal_skill_param() const + { + return _impl_.skill_param_; + } + inline int32_t SkillMsg::skill_param() const + { + // @@protoc_insertion_point(field_get:protobuf.SkillMsg.skill_param) + return _internal_skill_param(); + } + inline void SkillMsg::_internal_set_skill_param(int32_t value) + { + _impl_.skill_param_ = value; + } + inline void SkillMsg::set_skill_param(int32_t value) + { + _internal_set_skill_param(value); + // @@protoc_insertion_point(field_set:protobuf.SkillMsg.skill_param) + } + #ifdef __GNUC__ #pragma GCC diagnostic pop #endif // __GNUC__ diff --git a/CAPI/cpp/proto/MessageType.pb.cc b/CAPI/cpp/proto/MessageType.pb.cc index d00f04c..08504ac 100644 --- a/CAPI/cpp/proto/MessageType.pb.cc +++ b/CAPI/cpp/proto/MessageType.pb.cc @@ -30,49 +30,49 @@ static constexpr ::_pbi::MigrationSchema* schemas = nullptr; static constexpr ::_pb::Message* const* file_default_instances = nullptr; const char descriptor_table_protodef_MessageType_2eproto[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = - "\n\021MessageType.proto\022\010protobuf*\202\001\n\nBullet" - "Type\022\024\n\020NULL_BULLET_TYPE\020\000\022\020\n\014FLYING_KNI" - "FE\020\001\022\034\n\030COMMON_ATTACK_OF_TRICKER\020\002\022\r\n\tBO" - "MB_BOMB\020\003\022\020\n\014JUMPY_DUMPTY\020\004\022\r\n\tATOM_BOMB" - "\020\005*\241\001\n\tPlaceType\022\023\n\017NULL_PLACE_TYPE\020\000\022\010\n" - "\004LAND\020\001\022\010\n\004WALL\020\002\022\t\n\005GRASS\020\003\022\r\n\tCLASSROO" - "M\020\004\022\010\n\004GATE\020\005\022\017\n\013HIDDEN_GATE\020\006\022\n\n\006WINDOW" - "\020\007\022\t\n\005DOOR3\020\010\022\t\n\005DOOR5\020\t\022\t\n\005DOOR6\020\n\022\t\n\005C" - "HEST\020\013*8\n\tShapeType\022\023\n\017NULL_SHAPE_TYPE\020\000" - "\022\n\n\006CIRCLE\020\001\022\n\n\006SQUARE\020\002*\256\001\n\010PropType\022\022\n" - "\016NULL_PROP_TYPE\020\000\022\r\n\tADD_SPEED\020\001\022\035\n\031ADD_" - "LIFE_OR_CLAIRAUDIENCE\020\002\022\020\n\014ADD_HP_OR_AP\020" - "\003\022\023\n\017SHIELD_OR_SPEAR\020\004\022\010\n\004KEY3\020\005\022\010\n\004KEY5" - "\020\006\022\010\n\004KEY6\020\007\022\033\n\027RECOVERY_FROM_DIZZINESS\020" - "\010*n\n\017StudentBuffType\022\023\n\017NULL_SBUFF_TYPE\020" - "\000\022\025\n\021STUDENT_ADD_SPEED\020\001\022\014\n\010ADD_LIFE\020\002\022\n" - "\n\006SHIELD\020\003\022\025\n\021STUDENT_INVISIBLE\020\004*\251\002\n\013Pl" - "ayerState\022\017\n\013NULL_STATUS\020\000\022\010\n\004IDLE\020\001\022\014\n\010" - "LEARNING\020\002\022\014\n\010ADDICTED\020\003\022\010\n\004QUIT\020\004\022\r\n\tGR" - "ADUATED\020\005\022\013\n\007TREATED\020\006\022\013\n\007RESCUED\020\007\022\013\n\007S" - "TUNNED\020\010\022\014\n\010TREATING\020\t\022\014\n\010RESCUING\020\n\022\014\n\010" - "SWINGING\020\013\022\r\n\tATTACKING\020\014\022\013\n\007LOCKING\020\r\022\r" - "\n\tRUMMAGING\020\016\022\014\n\010CLIMBING\020\017\022\023\n\017OPENING_A" - "_CHEST\020\020\022\027\n\023USING_SPECIAL_SKILL\020\021\022\022\n\016OPE" - "NING_A_GATE\020\022*~\n\017TrickerBuffType\022\023\n\017NULL" - "_TBUFF_TYPE\020\000\022\025\n\021TRICKER_ADD_SPEED\020\001\022\t\n\005" - "SPEAR\020\002\022\n\n\006ADD_AP\020\003\022\021\n\rCLAIRAUDIENCE\020\004\022\025" - "\n\021TRICKER_INVISIBLE\020\005*J\n\nPlayerType\022\024\n\020N" - "ULL_PLAYER_TYPE\020\000\022\022\n\016STUDENT_PLAYER\020\001\022\022\n" - "\016TRICKER_PLAYER\020\002*\177\n\013StudentType\022\025\n\021NULL" - "_STUDENT_TYPE\020\000\022\013\n\007ATHLETE\020\001\022\013\n\007TEACHER\020" - "\002\022\026\n\022STRAIGHT_A_STUDENT\020\003\022\t\n\005ROBOT\020\004\022\016\n\n" - "TECH_OTAKU\020\005\022\014\n\010SUNSHINE\020\006*Z\n\013TrickerTyp" - "e\022\025\n\021NULL_TRICKER_TYPE\020\000\022\014\n\010ASSASSIN\020\001\022\010" - "\n\004KLEE\020\002\022\022\n\016A_NOISY_PERSON\020\003\022\010\n\004IDOL\020\004*P" - "\n\tGameState\022\023\n\017NULL_GAME_STATE\020\000\022\016\n\nGAME" - "_START\020\001\022\020\n\014GAME_RUNNING\020\002\022\014\n\010GAME_END\020\003" - "b\006proto3"; + "\n\021MessageType.proto\022\010protobuf*\177\n\nBulletT" + "ype\022\024\n\020NULL_BULLET_TYPE\020\000\022\020\n\014FLYING_KNIF" + "E\020\001\022\034\n\030COMMON_ATTACK_OF_TRICKER\020\002\022\r\n\tBOM" + "B_BOMB\020\003\022\020\n\014JUMPY_DUMPTY\020\004\022\n\n\006STRIKE\020\005*\241" + "\001\n\tPlaceType\022\023\n\017NULL_PLACE_TYPE\020\000\022\010\n\004LAN" + "D\020\001\022\010\n\004WALL\020\002\022\t\n\005GRASS\020\003\022\r\n\tCLASSROOM\020\004\022" + "\010\n\004GATE\020\005\022\017\n\013HIDDEN_GATE\020\006\022\n\n\006WINDOW\020\007\022\t" + "\n\005DOOR3\020\010\022\t\n\005DOOR5\020\t\022\t\n\005DOOR6\020\n\022\t\n\005CHEST" + "\020\013*8\n\tShapeType\022\023\n\017NULL_SHAPE_TYPE\020\000\022\n\n\006" + "CIRCLE\020\001\022\n\n\006SQUARE\020\002*\302\001\n\010PropType\022\022\n\016NUL" + "L_PROP_TYPE\020\000\022\r\n\tADD_SPEED\020\001\022\035\n\031ADD_LIFE" + "_OR_CLAIRAUDIENCE\020\002\022\020\n\014ADD_HP_OR_AP\020\003\022\023\n" + "\017SHIELD_OR_SPEAR\020\004\022\010\n\004KEY3\020\005\022\010\n\004KEY5\020\006\022\010" + "\n\004KEY6\020\007\022\033\n\027RECOVERY_FROM_DIZZINESS\020\010\022\022\n" + "\016CRAFTING_BENCH\020\t*n\n\017StudentBuffType\022\023\n\017" + "NULL_SBUFF_TYPE\020\000\022\025\n\021STUDENT_ADD_SPEED\020\001" + "\022\014\n\010ADD_LIFE\020\002\022\n\n\006SHIELD\020\003\022\025\n\021STUDENT_IN" + "VISIBLE\020\004*\251\002\n\013PlayerState\022\017\n\013NULL_STATUS" + "\020\000\022\010\n\004IDLE\020\001\022\014\n\010LEARNING\020\002\022\014\n\010ADDICTED\020\003" + "\022\010\n\004QUIT\020\004\022\r\n\tGRADUATED\020\005\022\013\n\007TREATED\020\006\022\013" + "\n\007RESCUED\020\007\022\013\n\007STUNNED\020\010\022\014\n\010TREATING\020\t\022\014" + "\n\010RESCUING\020\n\022\014\n\010SWINGING\020\013\022\r\n\tATTACKING\020" + "\014\022\013\n\007LOCKING\020\r\022\r\n\tRUMMAGING\020\016\022\014\n\010CLIMBIN" + "G\020\017\022\023\n\017OPENING_A_CHEST\020\020\022\027\n\023USING_SPECIA" + "L_SKILL\020\021\022\022\n\016OPENING_A_GATE\020\022*~\n\017Tricker" + "BuffType\022\023\n\017NULL_TBUFF_TYPE\020\000\022\025\n\021TRICKER" + "_ADD_SPEED\020\001\022\t\n\005SPEAR\020\002\022\n\n\006ADD_AP\020\003\022\021\n\rC" + "LAIRAUDIENCE\020\004\022\025\n\021TRICKER_INVISIBLE\020\005*J\n" + "\nPlayerType\022\024\n\020NULL_PLAYER_TYPE\020\000\022\022\n\016STU" + "DENT_PLAYER\020\001\022\022\n\016TRICKER_PLAYER\020\002*\177\n\013Stu" + "dentType\022\025\n\021NULL_STUDENT_TYPE\020\000\022\013\n\007ATHLE" + "TE\020\001\022\013\n\007TEACHER\020\002\022\026\n\022STRAIGHT_A_STUDENT\020" + "\003\022\t\n\005ROBOT\020\004\022\016\n\nTECH_OTAKU\020\005\022\014\n\010SUNSHINE" + "\020\006*Z\n\013TrickerType\022\025\n\021NULL_TRICKER_TYPE\020\000" + "\022\014\n\010ASSASSIN\020\001\022\010\n\004KLEE\020\002\022\022\n\016A_NOISY_PERS" + "ON\020\003\022\010\n\004IDOL\020\004*P\n\tGameState\022\023\n\017NULL_GAME" + "_STATE\020\000\022\016\n\nGAME_START\020\001\022\020\n\014GAME_RUNNING" + "\020\002\022\014\n\010GAME_END\020\003b\006proto3"; static ::_pbi::once_flag descriptor_table_MessageType_2eproto_once; const ::_pbi::DescriptorTable descriptor_table_MessageType_2eproto = { false, false, - 1488, + 1504, descriptor_table_protodef_MessageType_2eproto, "MessageType.proto", &descriptor_table_MessageType_2eproto_once, @@ -179,6 +179,7 @@ namespace protobuf case 6: case 7: case 8: + case 9: return true; default: return false; diff --git a/CAPI/cpp/proto/MessageType.pb.h b/CAPI/cpp/proto/MessageType.pb.h index b4b70cf..b5a62b3 100644 --- a/CAPI/cpp/proto/MessageType.pb.h +++ b/CAPI/cpp/proto/MessageType.pb.h @@ -57,13 +57,13 @@ namespace protobuf COMMON_ATTACK_OF_TRICKER = 2, BOMB_BOMB = 3, JUMPY_DUMPTY = 4, - ATOM_BOMB = 5, + STRIKE = 5, BulletType_INT_MIN_SENTINEL_DO_NOT_USE_ = std::numeric_limits::min(), BulletType_INT_MAX_SENTINEL_DO_NOT_USE_ = std::numeric_limits::max() }; bool BulletType_IsValid(int value); constexpr BulletType BulletType_MIN = NULL_BULLET_TYPE; - constexpr BulletType BulletType_MAX = ATOM_BOMB; + constexpr BulletType BulletType_MAX = STRIKE; constexpr int BulletType_ARRAYSIZE = BulletType_MAX + 1; const ::PROTOBUF_NAMESPACE_ID::EnumDescriptor* BulletType_descriptor(); @@ -163,12 +163,13 @@ namespace protobuf KEY5 = 6, KEY6 = 7, RECOVERY_FROM_DIZZINESS = 8, + CRAFTING_BENCH = 9, PropType_INT_MIN_SENTINEL_DO_NOT_USE_ = std::numeric_limits::min(), PropType_INT_MAX_SENTINEL_DO_NOT_USE_ = std::numeric_limits::max() }; bool PropType_IsValid(int value); constexpr PropType PropType_MIN = NULL_PROP_TYPE; - constexpr PropType PropType_MAX = RECOVERY_FROM_DIZZINESS; + constexpr PropType PropType_MAX = CRAFTING_BENCH; constexpr int PropType_ARRAYSIZE = PropType_MAX + 1; const ::PROTOBUF_NAMESPACE_ID::EnumDescriptor* PropType_descriptor(); diff --git a/CAPI/python/PyAPI/API.py b/CAPI/python/PyAPI/API.py index d1a6317..77c33c3 100644 --- a/CAPI/python/PyAPI/API.py +++ b/CAPI/python/PyAPI/API.py @@ -43,8 +43,8 @@ class StudentAPI(IStudentAPI, IGameTimer): def ThrowProp(self, propType: THUAI6.PropType) -> Future[bool]: return self.__pool.submit(self.__logic.ThrowProp, propType) - def UseSkill(self, skillID: int) -> Future[bool]: - return self.__pool.submit(self.__logic.UseSkill, skillID) + def UseSkill(self, skillID: int, skillParam: int = 0) -> Future[bool]: + return self.__pool.submit(self.__logic.UseSkill, skillID, skillParam) # 与地图交互相关 def OpenDoor(self) -> Future[bool]: @@ -224,8 +224,8 @@ class TrickerAPI(ITrickerAPI, IGameTimer): def ThrowProp(self, propType: THUAI6.PropType) -> Future[bool]: return self.__pool.submit(self.__logic.ThrowProp, propType) - def UseSkill(self, skillID: int) -> Future[bool]: - return self.__pool.submit(self.__logic.UseSkill, skillID) + def UseSkill(self, skillID: int, skillParam: int = 0) -> Future[bool]: + return self.__pool.submit(self.__logic.UseSkill, skillID, skillParam) # 与地图交互相关 def OpenDoor(self) -> Future[bool]: diff --git a/CAPI/python/PyAPI/Communication.py b/CAPI/python/PyAPI/Communication.py index 7090add..15135d2 100644 --- a/CAPI/python/PyAPI/Communication.py +++ b/CAPI/python/PyAPI/Communication.py @@ -91,14 +91,14 @@ class Communication: else: return throwResult.act_success - def UseSkill(self, skillID: int, playerID: int) -> bool: + def UseSkill(self, skillID: int, skillParam: int, playerID: int) -> bool: try: with self.__mtxLimit: if self.__counter >= self.__limit: return False self.__counter += 1 useResult = self.__THUAI6Stub.UseSkill( - THUAI62Proto.THUAI62ProtobufSkill(skillID, playerID) + THUAI62Proto.THUAI62ProtobufSkill(skillID, skillParam, playerID) ) except grpc.RpcError as e: return False diff --git a/CAPI/python/PyAPI/DebugAPI.py b/CAPI/python/PyAPI/DebugAPI.py index 891d35a..ad9374e 100644 --- a/CAPI/python/PyAPI/DebugAPI.py +++ b/CAPI/python/PyAPI/DebugAPI.py @@ -132,13 +132,13 @@ class StudentDebugAPI(IStudentAPI, IGameTimer): return self.__pool.submit(logThrow) - def UseSkill(self, skillID: int) -> Future[bool]: + def UseSkill(self, skillID: int, skillParam: int = 0) -> Future[bool]: self.__logger.info( - f"UseSkill: skillID = {skillID}, called at {self.__GetTime()}ms" + f"UseSkill: skillID = {skillID}, skillParam = {skillParam}, called at {self.__GetTime()}ms" ) def logUse() -> bool: - result = self.__logic.UseSkill(skillID) + result = self.__logic.UseSkill(skillID, skillParam) if not result: self.__logger.warning(f"UseSkill: failed at {self.__GetTime()}ms") return result @@ -600,13 +600,13 @@ class TrickerDebugAPI(ITrickerAPI, IGameTimer): return self.__pool.submit(logThrow) - def UseSkill(self, skillID: int) -> Future[bool]: + def UseSkill(self, skillID: int, skillParam: int = 0) -> Future[bool]: self.__logger.info( - f"UseSkill: skillID = {skillID}, called at {self.__GetTime()}ms" + f"UseSkill: skillID = {skillID}, skillParam = {skillParam}, called at {self.__GetTime()}ms" ) def logUse() -> bool: - result = self.__logic.UseSkill(skillID) + result = self.__logic.UseSkill(skillID, skillParam) if not result: self.__logger.warning(f"UseSkill: failed at {self.__GetTime()}ms") return result diff --git a/CAPI/python/PyAPI/Interface.py b/CAPI/python/PyAPI/Interface.py index 43c2965..40185e3 100644 --- a/CAPI/python/PyAPI/Interface.py +++ b/CAPI/python/PyAPI/Interface.py @@ -80,7 +80,7 @@ class ILogic(metaclass=ABCMeta): pass @abstractmethod - def UseSkill(self, skillID: int) -> bool: + def UseSkill(self, skillID: int, skillParam: int) -> bool: pass @abstractmethod @@ -201,7 +201,7 @@ class IAPI(metaclass=ABCMeta): pass @abstractmethod - def UseSkill(self, skillID: int) -> Future[bool]: + def UseSkill(self, skillID: int, skillParam: int = 0) -> Future[bool]: pass @abstractmethod diff --git a/CAPI/python/PyAPI/logic.py b/CAPI/python/PyAPI/logic.py index 128cfdb..e4e6e30 100644 --- a/CAPI/python/PyAPI/logic.py +++ b/CAPI/python/PyAPI/logic.py @@ -190,9 +190,9 @@ class Logic(ILogic): self.__logger.debug("Called ThrowProp") return self.__comm.ThrowProp(propType, self.__playerID) - def UseSkill(self, skillID: int) -> bool: + def UseSkill(self, skillID: int, skillParam: int) -> bool: self.__logger.debug("Called UseSkill") - return self.__comm.UseSkill(skillID, self.__playerID) + return self.__comm.UseSkill(skillID, skillParam, self.__playerID) def SendMessage(self, toID: int, message: Union[str, bytes]) -> bool: self.__logger.debug("Called SendMessage") diff --git a/CAPI/python/PyAPI/structures.py b/CAPI/python/PyAPI/structures.py index f28fbe4..aac8151 100644 --- a/CAPI/python/PyAPI/structures.py +++ b/CAPI/python/PyAPI/structures.py @@ -52,6 +52,7 @@ class PropType(Enum): AddHpOrAp = 6 ShieldOrSpear = 7 RecoveryFromDizziness = 8 + CraftingBench = 9 class BulletType(Enum): @@ -60,7 +61,7 @@ class BulletType(Enum): CommonAttackOfTricker = 2 BombBomb = 3 JumpyDumpty = 4 - AtomBomb = 5 + Strike = 5 class StudentType(Enum): diff --git a/CAPI/python/PyAPI/utils.py b/CAPI/python/PyAPI/utils.py index 1b05b2e..03128a1 100644 --- a/CAPI/python/PyAPI/utils.py +++ b/CAPI/python/PyAPI/utils.py @@ -109,6 +109,7 @@ class Proto2THUAI6(NoInstance): MessageType.ADD_LIFE_OR_CLAIRAUDIENCE: THUAI6.PropType.AddLifeOrClairaudience, MessageType.SHIELD_OR_SPEAR: THUAI6.PropType.ShieldOrSpear, MessageType.RECOVERY_FROM_DIZZINESS: THUAI6.PropType.RecoveryFromDizziness, + MessageType.CRAFTING_BENCH: THUAI6.PropType.CraftingBench, } playerTypeDict: Final[dict] = { @@ -187,7 +188,7 @@ class Proto2THUAI6(NoInstance): MessageType.BOMB_BOMB: THUAI6.BulletType.BombBomb, MessageType.COMMON_ATTACK_OF_TRICKER: THUAI6.BulletType.CommonAttackOfTricker, MessageType.JUMPY_DUMPTY: THUAI6.BulletType.JumpyDumpty, - MessageType.ATOM_BOMB: THUAI6.BulletType.AtomBomb, + MessageType.STRIKE: THUAI6.BulletType.Strike, } # 用于将Proto的对象转为THUAI6的对象 @@ -357,6 +358,7 @@ class THUAI62Proto(NoInstance): THUAI6.PropType.AddLifeOrClairaudience: MessageType.ADD_LIFE_OR_CLAIRAUDIENCE, THUAI6.PropType.AddSpeed: MessageType.ADD_SPEED, THUAI6.PropType.ShieldOrSpear: MessageType.SHIELD_OR_SPEAR, + THUAI6.PropType.CraftingBench: MessageType.CRAFTING_BENCH, } # 用于将THUAI6的对象转为Proto的对象 @@ -421,5 +423,9 @@ class THUAI62Proto(NoInstance): return Message2Server.AttackMsg(player_id=id, angle=angle) @staticmethod - def THUAI62ProtobufSkill(skillID: int, id: int) -> Message2Server.SkillMsg: - return Message2Server.SkillMsg(player_id=id, skill_id=skillID) + def THUAI62ProtobufSkill( + skillID: int, skillParam: int, id: int + ) -> Message2Server.SkillMsg: + return Message2Server.SkillMsg( + player_id=id, skill_id=skillID, skill_param=skillParam + ) diff --git a/dependency/proto/Message2Server.proto b/dependency/proto/Message2Server.proto index d764f5e..db65a11 100755 --- a/dependency/proto/Message2Server.proto +++ b/dependency/proto/Message2Server.proto @@ -61,6 +61,7 @@ message SkillMsg { int64 player_id = 1; int32 skill_id = 2; + int32 skill_param = 3; } // 基本继承于THUAI5,为了使发送的信息尽可能不被浪费,暂定不发这类大包。 diff --git a/dependency/proto/MessageType.proto b/dependency/proto/MessageType.proto index 9acbccb..77a26b1 100755 --- a/dependency/proto/MessageType.proto +++ b/dependency/proto/MessageType.proto @@ -9,7 +9,7 @@ enum BulletType COMMON_ATTACK_OF_TRICKER = 2; BOMB_BOMB = 3; JUMPY_DUMPTY = 4; - ATOM_BOMB = 5; + STRIKE = 5; } enum PlaceType // 地图中的所有物件类型 @@ -49,6 +49,7 @@ enum PropType // 地图中的可拾取道具类型 KEY5 = 6; KEY6 = 7; RECOVERY_FROM_DIZZINESS = 8; + CRAFTING_BENCH = 9; } enum StudentBuffType // 人类可用的增益效果类型 @@ -78,7 +79,7 @@ enum PlayerState LOCKING = 13; RUMMAGING = 14; CLIMBING = 15; // 翻窗 - OPENING_A_CHEST =16; + OPENING_A_CHEST = 16; USING_SPECIAL_SKILL = 17; OPENING_A_GATE =18; } @@ -109,7 +110,7 @@ enum StudentType TEACHER = 2; STRAIGHT_A_STUDENT = 3; ROBOT = 4; - TECH_OTAKU =5; + TECH_OTAKU = 5; SUNSHINE = 6; }