File tree Expand file tree Collapse file tree 2 files changed +29
-2
lines changed
src/DevChatter.Bot.Modules.WastefulGame Expand file tree Collapse file tree 2 files changed +29
-2
lines changed Original file line number Diff line number Diff line change @@ -7,8 +7,11 @@ namespace DevChatter.Bot.Modules.WastefulGame.Commands.Operations
7
7
{
8
8
public class LeaveTeamOperation : BaseGameCommandOperation
9
9
{
10
+ private readonly IGameRepository _gameRepository ;
11
+
10
12
public LeaveTeamOperation ( IGameRepository gameRepository )
11
13
{
14
+ _gameRepository = gameRepository ;
12
15
}
13
16
14
17
public override List < string > OperandWords { get ; }
@@ -17,7 +20,20 @@ public LeaveTeamOperation(IGameRepository gameRepository)
17
20
public override string TryToExecute ( CommandReceivedEventArgs eventArgs ,
18
21
Survivor survivor )
19
22
{
20
- return "You cannot leave teams yet. Please wait for this feature." ;
23
+ Team team = survivor . Team ;
24
+
25
+ if ( team == null )
26
+ {
27
+ return "You are not currently on a team." ;
28
+ }
29
+
30
+ if ( survivor . LeaveTeam ( ) )
31
+ {
32
+ _gameRepository . Update ( survivor ) ;
33
+ return $ "You left the { team . Name } team.";
34
+ }
35
+
36
+ return $ "Failed to leave the team.";
21
37
}
22
38
}
23
39
}
Original file line number Diff line number Diff line change @@ -20,7 +20,7 @@ public Survivor(string displayName, string userId)
20
20
public string UserId { get ; set ; }
21
21
public string DisplayName { get ; set ; }
22
22
public Team Team { get ; set ; }
23
- public long Money { get ; set ; }
23
+ public long Money { get ; set ; } = 100 ;
24
24
public List < GameEndRecord > GameEndRecords { get ; set ; }
25
25
= new List < GameEndRecord > ( ) ;
26
26
@@ -71,5 +71,16 @@ public bool BuyItem(ShopItem shopItem)
71
71
}
72
72
return false ;
73
73
}
74
+
75
+ public bool LeaveTeam ( )
76
+ {
77
+ if ( Team == null )
78
+ {
79
+ return false ;
80
+ }
81
+
82
+ Team = null ;
83
+ return true ;
84
+ }
74
85
}
75
86
}
You can’t perform that action at this time.
0 commit comments