From 4ccb6cf9122b6eab10a3ed4f471e1b2ad448d485 Mon Sep 17 00:00:00 2001 From: shangfengh <3495281661@qq.com> Date: Sat, 4 Mar 2023 22:50:36 +0800 Subject: [PATCH 1/8] feat: :sparkles: add the fuction of Stop --- logic/GameClass/GameObj/Character/Character.cs | 1 + logic/Gaming/ActionManager.cs | 14 ++++++++++++++ logic/Gaming/Game.cs | 12 ++++++++++++ logic/Preparation/Utility/EnumType.cs | 3 +++ 4 files changed, 30 insertions(+) diff --git a/logic/GameClass/GameObj/Character/Character.cs b/logic/GameClass/GameObj/Character/Character.cs index 6ab6ba1..033de45 100644 --- a/logic/GameClass/GameObj/Character/Character.cs +++ b/logic/GameClass/GameObj/Character/Character.cs @@ -477,6 +477,7 @@ namespace GameClass.GameObj playerState = playerStateType; CanMove = false; IsResetting = true; + Position = GameData.PosWhoDie; } } diff --git a/logic/Gaming/ActionManager.cs b/logic/Gaming/ActionManager.cs index 16df5fc..20c00d8 100644 --- a/logic/Gaming/ActionManager.cs +++ b/logic/Gaming/ActionManager.cs @@ -22,6 +22,20 @@ namespace Gaming return true; } + public bool Stop(Character player) + { + if (player.PlayerState == PlayerStateType.IsRescuing || player.PlayerState == PlayerStateType.IsRescued + || player.PlayerState == PlayerStateType.IsFixing || player.PlayerState == PlayerStateType.IsMoving + || player.PlayerState == PlayerStateType.IsTreated || player.PlayerState == PlayerStateType.IsTreating + || player.PlayerState == PlayerStateType.IsClosingDoor || player.PlayerState == PlayerStateType.IsOpeningDoor + || player.PlayerState == PlayerStateType.IsClimbingThtoughWindows) + { + player.PlayerState = PlayerStateType.Null; + return true; + } + return false; + } + public bool Fix(Student player)// 自动检查有无发电机可修 { if (player.PlayerState != PlayerStateType.Null || player.IsGhost()) diff --git a/logic/Gaming/Game.cs b/logic/Gaming/Game.cs index cf905e7..2b578ec 100644 --- a/logic/Gaming/Game.cs +++ b/logic/Gaming/Game.cs @@ -242,6 +242,18 @@ namespace Gaming } return false; } + public bool Stop(long playerID) + { + if (!gameMap.Timer.IsGaming) + return false; + Character player = gameMap.FindPlayer(playerID); + if (player != null) + { + return actionManager.Stop(player); + } + return false; + } + public void Attack(long playerID, double angle) { if (!gameMap.Timer.IsGaming) diff --git a/logic/Preparation/Utility/EnumType.cs b/logic/Preparation/Utility/EnumType.cs index 19d3a04..4bb5146 100644 --- a/logic/Preparation/Utility/EnumType.cs +++ b/logic/Preparation/Utility/EnumType.cs @@ -19,6 +19,9 @@ namespace Preparation.Utility IsRescued = 10, IsStunned = 11, IsTryingToAttack = 12,//指前摇 + IsOpeningDoor = 13, + IsClosingDoor = 14, + IsClimbingThtoughWindows = 15, } public enum GameObjType { From b1b7587eded14b05095b30a333b103b91a25d458 Mon Sep 17 00:00:00 2001 From: shangfengh <3495281661@qq.com> Date: Sat, 4 Mar 2023 23:29:50 +0800 Subject: [PATCH 2/8] fix: :bug: fix the deficiency of skill --- logic/GameClass/GameObj/Character/Character.cs | 2 +- logic/GameClass/Skill/ActiveSkill.cs | 4 ++++ logic/Preparation/Utility/EnumType.cs | 2 +- logic/Preparation/Utility/GameData.cs | 2 +- 4 files changed, 7 insertions(+), 3 deletions(-) diff --git a/logic/GameClass/GameObj/Character/Character.cs b/logic/GameClass/GameObj/Character/Character.cs index 033de45..95788f8 100644 --- a/logic/GameClass/GameObj/Character/Character.cs +++ b/logic/GameClass/GameObj/Character/Character.cs @@ -65,7 +65,7 @@ namespace GameClass.GameObj } set { - if (!(value == PlayerStateType.IsMoving || value == PlayerStateType.Null)) + if (!(value == PlayerStateType.IsMoving)) lock (gameObjLock) IsMoving = false; diff --git a/logic/GameClass/Skill/ActiveSkill.cs b/logic/GameClass/Skill/ActiveSkill.cs index 87ff08c..c67e969 100644 --- a/logic/GameClass/Skill/ActiveSkill.cs +++ b/logic/GameClass/Skill/ActiveSkill.cs @@ -214,6 +214,10 @@ namespace GameClass.Skill { case BecomeInvisible: return ActiveSkillType.BecomeInvisible; + case UseKnife: + return ActiveSkillType.UseKnife; + case BeginToCharge: + return ActiveSkillType.BeginToCharge; default: return ActiveSkillType.Null; } diff --git a/logic/Preparation/Utility/EnumType.cs b/logic/Preparation/Utility/EnumType.cs index 4bb5146..37fffbe 100644 --- a/logic/Preparation/Utility/EnumType.cs +++ b/logic/Preparation/Utility/EnumType.cs @@ -82,7 +82,7 @@ namespace Preparation.Utility NuclearWeapon = 3, SuperFast = 4, UseKnife = 5, - ASkill5 = 6 + BeginToCharge = 6 } public enum PassiveSkillType { diff --git a/logic/Preparation/Utility/GameData.cs b/logic/Preparation/Utility/GameData.cs index 813cb0a..51b3875 100644 --- a/logic/Preparation/Utility/GameData.cs +++ b/logic/Preparation/Utility/GameData.cs @@ -7,7 +7,7 @@ namespace Preparation.Utility { #region 基本常数与常方法 public const int numOfPosGridPerCell = 1000; // 每格的【坐标单位】数 - public const int numOfStepPerSecond = 100; // 每秒行走的步数 + public const int numOfStepPerSecond = 20; // 每秒行走的步数 public const int frameDuration = 50; // 每帧时长 public const int lengthOfMap = 50000; // 地图长度 From 0d77aad0b3e0b42296e2e67c7a93be213bbdd614 Mon Sep 17 00:00:00 2001 From: gsy1519 <614054460@qq.com> Date: Sat, 4 Mar 2023 23:34:27 +0800 Subject: [PATCH 3/8] feat: update ReportGame --- logic/Server/GameServer.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/logic/Server/GameServer.cs b/logic/Server/GameServer.cs index 83869d6..cd42329 100644 --- a/logic/Server/GameServer.cs +++ b/logic/Server/GameServer.cs @@ -114,6 +114,7 @@ namespace Server public void ReportGame() { //currentGameInfo = null; + var gameObjList = game.GetGameObj(); foreach (var kvp in semaDict) { From e785db4fc07b52420d998b41457f2988a6b49b16 Mon Sep 17 00:00:00 2001 From: Timothy Liu Date: Sat, 4 Mar 2023 23:35:43 +0800 Subject: [PATCH 4/8] chore: add eesast logo (32x32) --- resource/eesast_logo_32x32.png | Bin 0 -> 2976 bytes 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 resource/eesast_logo_32x32.png diff --git a/resource/eesast_logo_32x32.png b/resource/eesast_logo_32x32.png new file mode 100644 index 0000000000000000000000000000000000000000..49670adb9b377f1615290bb521833e27eb8153d1 GIT binary patch literal 2976 zcmV;R3t#k!P)004R>004l5008;`004mK004C`008P>0026e000+ooVrmw00006 zVoOIv0RI600RN!9r;`8x00(qQO+^Rd3knP=Cud_4xBvhOK}keGR9M56S8bG*)pgzH z+gG^?aVZL}jpXa&voc@@VuKq}@?4S4Ewf8>f{@I&w zhFH?m4++X9;stE*x5ShZ)8B=B^fsqnUu&6gMtt_8K3v${i@4q(ErvF>bfdd_s9|JT4J2ahA9Kw9z*K9L)ZrF#IhkL#jDL0%-*ha$;(J()Ar2YuM( zoSz*91dbhDVJxj-$Dd+L5gP<+u*>T^7VbU?0yTkFI@EDUodTJH;iMXB|n)h-zHvH0XP>BKxoKV{h{&l z=qHEXdH22gHte4_6OAWMV)3y)N($i@C* zAA+g^idweRVH~YyOY_+>8-uE~*d7~M*C5rMDH*?ec{>(#egGR8_)I3*nD4MLuQHCO z8Apg%PBvu8me!Gxjq5LH?|JU&t=M$^5)d;uawKV{FW0q>8)$j>0H$12hyH`bg>3l& zwsZ|!%CjYL2Kyo_->IeSg{p~)PyWppaNDM5A(=u2d7ID1JH=$$uVRTL-QEI2mwHHF@w07#|B zs6L(#eoGg(^(`OShnMeKjup=wh8(Z5%k#xHXYK=`13-<63Wu;aPW-w_m9ZCwYwF80 z4!(m|A6Nn>YM^=vF|Pq|9Y8f2WOirgFK$+7V#NchAXSY_NWkgoF1Xw+%WA6o_g9?a zi<9u?W1TqXscuw;vo@RKuMp!-0Iezth@P-PAI~M(zwT+7-na7PabU?5bbRdrTvr*M zL6+|#r7sd;5`o~WRg`-A8U}VBVp|i#QZj;|waD=xYN9dZ>a@=_)^@+1cpZr^K>dTi zM0q%?O-ufBHsUqoD+H^cNUG0~hV|2{!v_YnMlYK=ierl|1f|mSnX#dj!O~Yb=xhRr z1X-!)gbeQOj+4inMu}qBMvhDDIa$S7pRw&QK*BK_bYqO{i4V@2dUDC$9oT%+asWVDEJM79gaFArf-^v|49POs zq)>u*kC4U)S%#3suyF<(2jDwb1^{91mfg7eSNrgM`HGq1;y{$8QvJe^Z~C|M{;;X*-EVAzh>U9)9yj1UY+5QqLx5x%Oqw8A3vUTVC*Z#^HLfwG zWhLkC1JPoJT2@h3bQ;A&d7nK~B{!yN1+6RQ;M(#q(voj7ZuDjrx(7^CGZ$@_yaxbC z=Et=lpkfIc0&G?+K@||LB9MYLXboAGmh&$fHfA-zD+pT8Du7a-RoxP)Ja(k!lgFv>uR+2p2XNt)tQ)=TF3W;uD0`)nnabY3T8cS8J&N|%e}(dJI?={_t54<60ennVVKO~ctLYQ1#j!^> zd}8jgf8X&mzPasZfES{O&^UcErd+-lbxSJ z-BUbE2mf&q3L6h%!ovr+GLp@8Idd;DKBqvPimD0WV4Q{Zt)cMjK)#_c=dHJJY~H0< z&~plOYGC4~FWq@dZO;8!Lq3|th7gi03yD|t0>bJyev^)7L*+(D_6Cx%9War{_pU|# zKkb9b8H7ZpnDONE6&rJ#i3l#Dlld5%n{Bpn=d||YtKNPE^*n|*&uK?Kspg9f_18*1 zx)-rs$d)ZzO4;#iO!DBdZ~pa;iGT1%`a4r`-Phkh5_mkOIqEQu*O-VeHjdatT!~|P zxhB?c&vb>oBNBz(w=BT2|J;N6O2PcPW%7KVk5?mhH<066wxq^!r*ZTUJ9zUc)pm}(vSaZF+TtKSFj7f{M60p zubr|=;clZ~CUL4TD!l-22Fa$;;?J>)Zd=p5|71D0FX^Yczmc3 z_qu!qpPkr+=_?PRB`Y?6{HcR01Kiyd%xum;3@I3;{{Znr#Jb-nA_o?oduGK1tKR@r znGDTk269#pcp*u?bs1(qvJ9RI>Zw9YvGi7JxrW#^q) zG5IjedTlSmU&sqa#O)=(~N+N8&qU14W781;=B^0}TBKRpbDCgGhev zQ-rRi)6aaB^>EX>4U6ba`-PAZc)PV*mhnoa6Eg2ys>@ zD9TUE%t_@^00ScnE@KN5BNI!L6ay0=M1VBIWCJ6!R3OXP)X2ol#2my2%YaCrN-hBE W7ZG&wLN%2D0000 Date: Sat, 4 Mar 2023 23:53:30 +0800 Subject: [PATCH 5/8] fix: :bug: something unimportant --- logic/GameClass/GameObj/Character/Character.SkillManager.cs | 2 +- logic/GameClass/Skill/Occupation.cs | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/logic/GameClass/GameObj/Character/Character.SkillManager.cs b/logic/GameClass/GameObj/Character/Character.SkillManager.cs index bc6e7ad..587b090 100644 --- a/logic/GameClass/GameObj/Character/Character.SkillManager.cs +++ b/logic/GameClass/GameObj/Character/Character.SkillManager.cs @@ -12,7 +12,7 @@ namespace GameClass.GameObj private readonly IOccupation occupation; public IOccupation Occupation => occupation; - private Dictionary timeUntilActiveSkillAvailable; + private Dictionary timeUntilActiveSkillAvailable = new(); public Dictionary TimeUntilActiveSkillAvailable => timeUntilActiveSkillAvailable; public bool SetTimeUntilActiveSkillAvailable(ActiveSkillType activeSkillType, int timeUntilActiveSkillAvailable) diff --git a/logic/GameClass/Skill/Occupation.cs b/logic/GameClass/Skill/Occupation.cs index 18d7abf..26f8507 100644 --- a/logic/GameClass/Skill/Occupation.cs +++ b/logic/GameClass/Skill/Occupation.cs @@ -43,7 +43,7 @@ namespace GameClass.Skill public List ListOfIActiveSkill => new(new IActiveSkill[] { new BecomeInvisible(), new UseKnife() }); public List ListOfIPassiveSkill => new(new IPassiveSkill[] { }); } - public class Athlete : IOccupation + public class Athlete : IStudent { private const int moveSpeed = GameData.basicMoveSpeed; public int MoveSpeed => moveSpeed; @@ -59,7 +59,9 @@ namespace GameClass.Skill public BulletType InitBullet => BulletType.CommonAttackOfGhost; - public List ListOfIActiveSkill => new(new IActiveSkill[] { new BecomeInvisible(), new UseKnife() }); + public List ListOfIActiveSkill => new(new IActiveSkill[] { new BeginToCharge() }); public List ListOfIPassiveSkill => new(new IPassiveSkill[] { }); + + public int FixSpeed => GameData.basicFixSpeed; } } From 861e40e47c58b5b614727b603fd49426bcfbff5d Mon Sep 17 00:00:00 2001 From: gsy1519 <614054460@qq.com> Date: Sun, 5 Mar 2023 00:17:50 +0800 Subject: [PATCH 6/8] feat: :fire: continue to fit CopyInfo to new protos --- .../Character/Character.SkillManager.cs | 2 +- logic/Server/CopyInfo.cs | 82 +++++++++---------- 2 files changed, 41 insertions(+), 43 deletions(-) diff --git a/logic/GameClass/GameObj/Character/Character.SkillManager.cs b/logic/GameClass/GameObj/Character/Character.SkillManager.cs index bc6e7ad..587b090 100644 --- a/logic/GameClass/GameObj/Character/Character.SkillManager.cs +++ b/logic/GameClass/GameObj/Character/Character.SkillManager.cs @@ -12,7 +12,7 @@ namespace GameClass.GameObj private readonly IOccupation occupation; public IOccupation Occupation => occupation; - private Dictionary timeUntilActiveSkillAvailable; + private Dictionary timeUntilActiveSkillAvailable = new(); public Dictionary TimeUntilActiveSkillAvailable => timeUntilActiveSkillAvailable; public bool SetTimeUntilActiveSkillAvailable(ActiveSkillType activeSkillType, int timeUntilActiveSkillAvailable) diff --git a/logic/Server/CopyInfo.cs b/logic/Server/CopyInfo.cs index e9e4003..4aa22d9 100644 --- a/logic/Server/CopyInfo.cs +++ b/logic/Server/CopyInfo.cs @@ -8,7 +8,26 @@ namespace Server public static class CopyInfo { // 下面赋值为0的大概率是还没写完 2023-03-03 - private static MessageOfStudent Human(Character player) + /*public static MessageOfObj? Auto(GameObj gameObj) + { + if (gameObj.Type == Preparation.Utility.GameObjType.Character) + { + Character character = (Character)gameObj; + if (character.IsGhost()) + return Tri + } + else if (gameObj.Type == Preparation.Utility.GameObjType.Bullet) + return Bullet((Bullet)gameObj); + else if (gameObj.Type == Preparation.Utility.GameObjType.Prop) + return Prop((Prop)gameObj); + else if (gameObj.Type == Preparation.Utility.GameObjType.BombedBullet) + return BombedBullet((BombedBullet)gameObj); + else if (gameObj.Type == Preparation.Utility.GameObjType.PickedProp) + return PickedProp((PickedProp)gameObj); + else return null; //先写着防报错 + }*/ + + private static MessageOfStudent? Student(Character player) { MessageOfStudent msg = new MessageOfStudent(); if (player.IsGhost()) return null; @@ -19,7 +38,6 @@ namespace Server msg.Determination = player.HP; msg.FailNum = 0; msg.TimeUntilSkillAvailable = 0; - //msg.Place = 0; 下面写了 msg.StudentType = StudentType.NullStudentType; // 下面写 msg.Guid = 0; msg.State = StudentState.NullStatus; @@ -28,32 +46,7 @@ namespace Server msg.PlayerId = 0; msg.ViewRange = 0; msg.Radius = 0; - //msg.Buff[0] = StudentBuffType.NullSbuffType; 下面写了 - - /* THUAI5中的内容 - msg.BulletNum = player.BulletNum; - msg.CanMove = player.CanMove; - msg.CD = player.CD; - msg.GemNum = player.GemNum; - msg.Guid = player.ID; - msg.IsResetting = player.IsResetting; - - msg.LifeNum = player.DeathCount + 1; - msg.Radius = player.Radius; - msg.TimeUntilCommonSkillAvailable = player.TimeUntilCommonSkillAvailable; - msg.TeamID = player.TeamID; - msg.PlayerID = player.PlayerID; - msg.IsInvisible = player.IsInvisible; - msg.FacingDirection = player.FacingDirection; - - //应该要发队伍分数,这里先发个人分数 - msg.MessageOfHuman.Score = player.Score; - - //这条暂时没啥用 - msg.MessageOfHuman.TimeUntilUltimateSkillAvailable = 0; - - msg.MessageOfHuman.Vampire = player.Vampire;*/ foreach (KeyValuePair kvp in player.Buff) { @@ -78,19 +71,24 @@ namespace Server } } } - /*switch (player.Place) + switch (player.Place) { - case Preparation.Utility.PlaceType.Land: - msg.Place = PlaceType.Land; + case Preparation.Utility.PlaceType.EmergencyExit: + msg.Place = PlaceType.HiddenGate; break; - case Preparation.Utility.PlaceType.Grass1: - msg.Place = PlaceType.Grass; + case Preparation.Utility.PlaceType.Doorway: + msg.Place = PlaceType.Gate; break; - case Preparation.Utility.PlaceType.Grass2: + case Preparation.Utility.PlaceType.Grass: msg.Place = PlaceType.Grass; break; - case Preparation.Utility.PlaceType.Grass3: - msg.Place = PlaceType.Grass; + case Preparation.Utility.PlaceType.BirthPoint1: + case Preparation.Utility.PlaceType.BirthPoint2: + case Preparation.Utility.PlaceType.BirthPoint3: + case Preparation.Utility.PlaceType.BirthPoint4: + case Preparation.Utility.PlaceType.BirthPoint5: + case Preparation.Utility.PlaceType.Null: + msg.Place = PlaceType.Land; break; // case Preparation.Utility.PlaceType.Invisible: // msg.MessageOfHuman.Place = Communication.Proto.PlaceType.Invisible; @@ -98,20 +96,20 @@ namespace Server default: msg.Place = PlaceType.NullPlaceType; break; - }*/ + } //Character的储存方式可能得改,用enum type存道具和子弹,不应该用对象 //现在懒得改了,有时间再重整一波 - /*if (player.PropInventory == null) - msg.Prop = PropType.NullPropType; + if (player.PropInventory == null) + msg.Prop.Add(PropType.NullPropType); else { switch (player.PropInventory.GetPropType()) { case Preparation.Utility.PropType.Gem: - msg.Prop = PropType.NullPropType; + msg.Prop.Add(PropType.NullPropType); break; - case Preparation.Utility.PropType.addLIFE: + /*case Preparation.Utility.PropType.addLIFE: msg.MessageOfHuman.Prop = Communication.Proto.PropType.AddLife; break; case Preparation.Utility.PropType.addSpeed: @@ -125,9 +123,9 @@ namespace Server break; default: msg.Prop = PropType.NullPropType; - break; + break;*/ } - }*/ + } /*switch (player.PassiveSkillType) 需要对接一下,proto里似乎没有这个 { case Preparation.Utility.PassiveSkillType.RecoverAfterBattle: From d67736bca197275620d2064ffa44ba9e7e0eacbf Mon Sep 17 00:00:00 2001 From: Timothy Liu Date: Sun, 5 Mar 2023 00:28:29 +0800 Subject: [PATCH 7/8] docs: :memo: add markdown checkbox semantic intro --- README.md | 34 +++++++++++++++++++++++++++++----- 1 file changed, 29 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 5b244ff..f16f76b 100644 --- a/README.md +++ b/README.md @@ -21,7 +21,7 @@ GitLink 镜像地址:[THUAI6: GitLink Mirror](https://www.gitlink.org.cn/EESAS ### 配置说明 -本仓库使用 git 进行版本控制,为所有开发工作共用仓库,请勿上传不必要的文件。主目录文件结构非必要请勿修改,且主目录中已配置的`.gitignore`、`.gitattributes`文件非必要请勿修改;各子目录已预先包含使用`Visual Studio`开发的`.gitignore`模板,可以根据自身需要增加忽略规则;如有必要,可在子目录下自定义`.gitattributes`文件 +本仓库使用 Git 进行版本控制,为所有开发工作共用仓库,请勿上传不必要的文件。主目录文件结构非必要请勿修改,且主目录中已配置的 `.gitignore`、`.gitattributes` 文件非必要请勿修改;各子目录已预先包含使用 `Visual Studio` 开发的 `.gitignore` 模板,可以根据自身需要增加忽略规则;如有必要,可在子目录下自定义 `.gitattributes` 文件 ### 目录分配 @@ -46,7 +46,7 @@ GitLink 镜像地址:[THUAI6: GitLink Mirror](https://www.gitlink.org.cn/EESAS ### 关于社区开发者 -- 社区开发者开发工作请遵循 [THUAI6社区开发者贡献指南](./CONTRIBUTING.md) +- 社区开发者开发工作请遵循 [THUAI6 社区开发者贡献指南](./CONTRIBUTING.md) - 社区开发者贡献的代码请遵循 [Contributor Covenant Code of Conduct](./CODE_OF_CONDUCT.md) ### 开发流程 @@ -63,7 +63,7 @@ THUAI6 开发组成员与其他贡献者应当遵循以下流程: - 非必要请勿上传大文件到 Github -- commit 提交信息请遵循 Semantic Commit 规范,即:`type: content `格式 +- commit 提交信息请遵循 [Semantic Commits](https://www.conventionalcommits.org/zh-hans) 规范,即:`type: content` 格式 常用的 commit message type 包括: @@ -90,7 +90,7 @@ THUAI6 开发组成员与其他贡献者应当遵循以下流程: ## 代码风格 -本仓库严格规定了`C++`与`CSharp`代码风格,具体配置请参见 [.clang-format](.clang-format) +本仓库严格规定了 `C++` 与 `CSharp` 代码风格,具体配置请参见 [.clang-format](.clang-format) ### 风格说明 @@ -158,17 +158,41 @@ THUAI6 开发组成员与其他贡献者应当遵循以下流程: > - 命名允许较长,但不应过于啰嗦冗余,能完整表明意图即可。 + - 代码应保证良好的可读性;**禁止**中学 OI 竞赛的各种“卡常”奇技淫巧!!!效率并非总是最重要的,良好的可读性与可维护性往往更加重要 + - 熟练运用面向对象编程的思想,设计架构时尽可能降低模块与模块的耦合性,保证代码的可维护性 + - 慎用全局变量、全局函数等 + - 尽可能将各功能模块化,便于日后复用;尽可能降低类与类的耦合,善用继承与多态 + - 适当设计单元测试,保证代码的正确运行 + - 注意跨平台问题,代码需保证同时支持 Windows 与 Linux,避免直接的系统调用带来的跨平台问题 + - 善于使用 [Google](https://www.google.com/) 并使用[**英文**](https://en.wikipedia.org/wiki/American_English)搜索,善于查阅 [Microsoft Learn](https://learn.microsoft.com/)、[cppreference](https://en.cppreference.com/)、[StackOverflow](https://stackoverflow.com/) 以及第三方库官方文档等;不应轻信 [CSDN](https://www.csdn.net/) 等劣质博客社区以及[博客园](https://www.cnblogs.com/)、[简书](https://www.jianshu.com/)等质量参差不齐的博客社区,对其内容需全方位多角度仔细求证方可相信 + +- Pull requests 模板中的复选框采用 Markdown 格式: + + ```markdown + - [ ] 不勾选 + - [x] 勾选 + ``` + + 效果: + + - [ ] 不勾选 + - [x] 勾选 + - 注意维护开发文档,便于后来者快速了解本仓库代码结构 + - 小组内合理分工,避免个人任务量过重或过轻 -- 做好部会记录,及时完成工作任务,避免拖延到ddl + +- 做好部会记录,及时完成工作任务,避免拖延到 ddl + - 各组间多交流,相互了解各自的开发进度,加强协作,遇到困难互相帮助 + - 加油,奥里给 ,冲冲冲 ## 开发组成员 From f658bf8e1d3b4a1e0e0af8e5327664e657b4ebf7 Mon Sep 17 00:00:00 2001 From: gsy1519 <614054460@qq.com> Date: Sun, 5 Mar 2023 01:12:38 +0800 Subject: [PATCH 8/8] feat: :triangular_flag_on_post: succeed in moving character --- dependency/proto/Message2Server.proto | 21 ++++++++++++------ logic/ClientTest/Program.cs | 23 +++++++++++-------- logic/Gaming/Game.cs | 5 +++-- logic/Server/CopyInfo.cs | 32 +++++++++++++-------------- logic/Server/GameServer.cs | 22 +++++++++--------- 5 files changed, 58 insertions(+), 45 deletions(-) diff --git a/dependency/proto/Message2Server.proto b/dependency/proto/Message2Server.proto index 856115c..796e13e 100755 --- a/dependency/proto/Message2Server.proto +++ b/dependency/proto/Message2Server.proto @@ -18,38 +18,45 @@ message PlayerMsg message MoveMsg { int64 player_id = 1; - double angle = 2; - int64 time_in_milliseconds = 3; + PlayerType player_type = 2; + double angle = 3; + int64 time_in_milliseconds = 4; } message PropMsg { int64 player_id = 1; - PropType prop_type = 2; + PlayerType player_type = 2; + PropType prop_type = 3; } message SendMsg { int64 player_id = 1; - int64 to_player_id = 2; - string message = 3; + PlayerType player_type = 2; + int64 to_player_id = 3; + PlayerType to_player_type = 4; + string message = 5; } message TrickMsg // 相当于攻击 { int64 player_id = 1; - double angle = 2; + PlayerType player_type = 2; + double angle = 3; } message IDMsg { int64 player_id = 1; + PlayerType player_type = 2; } message SkillMsg { int64 player_id = 1; - int32 skill_id = 2; + PlayerType player_type = 2; + int32 skill_id = 3; } // 基本继承于THUAI5,为了使发送的信息尽可能不被浪费,暂定不发这类大包。 diff --git a/logic/ClientTest/Program.cs b/logic/ClientTest/Program.cs index 3d4cf80..c1a98aa 100644 --- a/logic/ClientTest/Program.cs +++ b/logic/ClientTest/Program.cs @@ -15,21 +15,26 @@ namespace ClientTest playerInfo.PlayerType = PlayerType.StudentPlayer; playerInfo.StudentType = StudentType.NullStudentType; var call = client.AddPlayer(playerInfo); + MoveMsg moveMsg = new(); + moveMsg.PlayerId = 0; + moveMsg.PlayerType = PlayerType.StudentPlayer; + moveMsg.TimeInMilliseconds = 100; + moveMsg.Angle = 0; + while (true) + { + Console.ReadLine(); + client.Move(moveMsg); + Console.WriteLine("Move!"); + } + while (await call.ResponseStream.MoveNext()) { var currentGameInfo = call.ResponseStream.Current; if (playerInfo.PlayerType == PlayerType.StudentPlayer) { - for (int i = 0; i < currentGameInfo.StudentMessage.Count; i++) - { - Console.WriteLine($"Human is at ({currentGameInfo.StudentMessage[i].X}, {currentGameInfo.StudentMessage[i].Y})"); - } - } - if (playerInfo.PlayerType == PlayerType.TrickerPlayer) - { - for (int i = 0; i < currentGameInfo.TrickerMessage.Count; i++) + for (int i = 0; i < currentGameInfo.ObjMessage.Count; i++) { - Console.WriteLine($"Butcher is at ({currentGameInfo.TrickerMessage[i].X}, {currentGameInfo.TrickerMessage[i].Y})"); + //Console.WriteLine($"Human is at ({currentGameInfo.StudentMessage[i].X}, {currentGameInfo.StudentMessage[i].Y})"); } } } diff --git a/logic/Gaming/Game.cs b/logic/Gaming/Game.cs index c9f5f4d..9ddee60 100644 --- a/logic/Gaming/Game.cs +++ b/logic/Gaming/Game.cs @@ -180,17 +180,18 @@ namespace Gaming Character? player = gameMap.FindPlayer(playerID); if (player != null) { - return actionManager.MovePlayer(player, moveTimeInMilliseconds, angle); + var res = actionManager.MovePlayer(player, moveTimeInMilliseconds, angle); #if DEBUG Console.WriteLine($"PlayerID:{playerID} move to ({player.Position.x},{player.Position.y})!"); #endif + return res; } else { - return false; #if DEBUG Console.WriteLine($"PlayerID:{playerID} player does not exists!"); #endif + return false; } } public bool Treat(long playerID, long playerTreatedID) diff --git a/logic/Server/CopyInfo.cs b/logic/Server/CopyInfo.cs index 4aa22d9..9a5b038 100644 --- a/logic/Server/CopyInfo.cs +++ b/logic/Server/CopyInfo.cs @@ -46,7 +46,7 @@ namespace Server msg.PlayerId = 0; msg.ViewRange = 0; msg.Radius = 0; - + foreach (KeyValuePair kvp in player.Buff) { @@ -109,21 +109,21 @@ namespace Server case Preparation.Utility.PropType.Gem: msg.Prop.Add(PropType.NullPropType); break; - /*case Preparation.Utility.PropType.addLIFE: - msg.MessageOfHuman.Prop = Communication.Proto.PropType.AddLife; - break; - case Preparation.Utility.PropType.addSpeed: - msg.MessageOfHuman.Prop = Communication.Proto.PropType.AddSpeed; - break; - case Preparation.Utility.PropType.Shield: - msg.MessageOfHuman.Prop = Communication.Proto.PropType.Shield; - break; - case Preparation.Utility.PropType.Spear: - msg.MessageOfHuman.Prop = Communication.Proto.PropType.Spear; - break; - default: - msg.Prop = PropType.NullPropType; - break;*/ + /*case Preparation.Utility.PropType.addLIFE: + msg.MessageOfHuman.Prop = Communication.Proto.PropType.AddLife; + break; + case Preparation.Utility.PropType.addSpeed: + msg.MessageOfHuman.Prop = Communication.Proto.PropType.AddSpeed; + break; + case Preparation.Utility.PropType.Shield: + msg.MessageOfHuman.Prop = Communication.Proto.PropType.Shield; + break; + case Preparation.Utility.PropType.Spear: + msg.MessageOfHuman.Prop = Communication.Proto.PropType.Spear; + break; + default: + msg.Prop = PropType.NullPropType; + break;*/ } } /*switch (player.PassiveSkillType) 需要对接一下,proto里似乎没有这个 diff --git a/logic/Server/GameServer.cs b/logic/Server/GameServer.cs index cd42329..1066a45 100644 --- a/logic/Server/GameServer.cs +++ b/logic/Server/GameServer.cs @@ -192,8 +192,9 @@ namespace Server { Game.PlayerInitInfo playerInitInfo = new(GetBirthPointIdx(request.PlayerType, request.PlayerId), PlayerTypeToTeamID(request.PlayerType), request.PlayerId, characterType); long newPlayerID = game.AddPlayer(playerInitInfo); - //if (newPlayerID == GameObj.invalidID) - //return; + if (newPlayerID == GameObj.invalidID) + return; + communicationToGameID[PlayerTypeToTeamID(request.PlayerType), request.PlayerId] = newPlayerID; // 内容待修改 var temp = (new SemaphoreSlim(0, 1), new SemaphoreSlim(0, 1)); bool start = false; @@ -239,7 +240,8 @@ namespace Server public override Task Move(MoveMsg request, ServerCallContext context) { Console.WriteLine($"Move ID: {request.PlayerId}, TimeInMilliseconds: {request.TimeInMilliseconds}"); - game.MovePlayer(request.PlayerId, (int)request.TimeInMilliseconds, request.Angle); + var gameID = communicationToGameID[PlayerTypeToTeamID(request.PlayerType), request.PlayerId]; + game.MovePlayer(gameID, (int)request.TimeInMilliseconds, request.Angle); // 之后game.MovePlayer可能改为bool类型 MoveRes moveRes = new(); moveRes.ActSuccess = true; @@ -258,13 +260,11 @@ namespace Server { return base.SendMessage(request, context); } - - public override Task UseProp(IDMsg request, ServerCallContext context) + public override Task UseProp(PropMsg request, ServerCallContext context) { return base.UseProp(request, context); } - - public override Task UseSkill(IDMsg request, ServerCallContext context) + public override Task UseSkill(SkillMsg request, ServerCallContext context) { return base.UseSkill(request, context); } @@ -273,13 +273,13 @@ namespace Server { return base.Graduate(request, context); } - public override Task StartHealMate(IDMsg request, ServerCallContext context) + public override Task StartRescueMate(IDMsg request, ServerCallContext context) { - return base.StartHealMate(request, context); + return base.StartRescueMate(request, context); } - public override Task StartHelpMate(IDMsg request, ServerCallContext context) + public override Task StartTreatMate(IDMsg request, ServerCallContext context) { - return base.StartHelpMate(request, context); + return base.StartTreatMate(request, context); } public override Task StartLearning(IDMsg request, ServerCallContext context) {