Skip to content

Commit

Permalink
新的提示系统
Browse files Browse the repository at this point in the history
  • Loading branch information
LTCatt committed Aug 23, 2021
1 parent 37ca14d commit 0d78ca0
Show file tree
Hide file tree
Showing 5 changed files with 77 additions and 55 deletions.
4 changes: 2 additions & 2 deletions Client/formMain.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@
<local:Timer x:Name="timerGame" HorizontalAlignment="Left" Height="40" Margin="434,21,0,0" VerticalAlignment="Top" Width="92" Visibility="Collapsed" Interval="999"/>
<Label x:Name="labGameObserve" Content="旁观者:3 人" Height="30" Margin="0,90,25,0" VerticalAlignment="Top" FontSize="16" VerticalContentAlignment="Center" Padding="0" HorizontalAlignment="Right" Opacity="0.5"/>
<StackPanel Orientation="Horizontal" x:Name="panGameSelect" Height="41" Margin="250,130,25,0" VerticalAlignment="Top">
<local:Button x:Name="btnGameSelect1" Height="40" Margin="45,0,0,0" Width="170" Text="提示长度:4 个字" />
<local:Button x:Name="btnGameSelect2" Height="40" Margin="30,0,0,0" Width="170" Text="提示类别:MC 物品" />
<local:Button x:Name="btnGameSelect1" Height="40" Margin="45,0,0,0" Width="170" Text="发送长度提示:4 个字" />
<local:Button x:Name="btnGameSelect2" Height="40" Margin="30,0,0,0" Width="170" Text="发送类别提示:MC 物品" />
</StackPanel>
</Grid>
<Grid x:Name="panRoom" d:IsHidden="True">
Expand Down
51 changes: 32 additions & 19 deletions Client/formMain.xaml.vb
Original file line number Diff line number Diff line change
Expand Up @@ -418,13 +418,10 @@ Public Class formMain
Private Sub timerGame_Tick() Handles timerGame.Tick
If UserState = UserStates.Game And Val(labGameTimer.Content) > 0 Then labGameTimer.Content = Val(labGameTimer.Content) - 1
End Sub
Private Sub btnGameSelect1_Click(sender As Object, e As EventArgs) Handles btnGameSelect1.Click
Dim th As New Thread(Sub() ClientSend("Select|0"))
th.Start()
End Sub
Private Sub btnGameSelect2_Click(sender As Object, e As EventArgs) Handles btnGameSelect2.Click
Dim th As New Thread(Sub() ClientSend("Select|1"))
th.Start()
Private Sub btnGameSelect1_Click(sender As Button, e As EventArgs) Handles btnGameSelect1.Click, btnGameSelect2.Click
Dim SendContent As String = sender.Tag
RunInThread(Sub() ClientSend(SendContent))
sender.IsEnabled = False
End Sub

#End Region
Expand Down Expand Up @@ -559,18 +556,34 @@ Public Class formMain
End Sub)

Case "Select"
'Select(String? 选择1, String? 选择2):改变选题区显示,若隐藏选题区则无参数
Dispatcher.Invoke(Sub()
If Parm = "" Then
'隐藏
panChat.Margin = New Thickness(250, 130, 25, 25)
Else
'显示
panChat.Margin = New Thickness(250, 200, 25, 25)
btnGameSelect1.Text = Parms(0)
btnGameSelect2.Text = Parms(1)
End If
End Sub)
'Select(String 选择1, String 选择2):改变选题区显示
RunInUi(Sub()
'显示
panChat.Margin = New Thickness(250, 200, 25, 25)
btnGameSelect1.Text = Parms(0)
btnGameSelect1.Tag = "Select|0"
btnGameSelect1.IsEnabled = True
btnGameSelect2.Text = Parms(1)
btnGameSelect2.Tag = "Select|1"
btnGameSelect2.IsEnabled = True
End Sub)

Case "Hint"
'Hint(String 提示1, String 提示2):让选题区显示提示选项
RunInUi(Sub()
'显示
panChat.Margin = New Thickness(250, 200, 25, 25)
btnGameSelect1.Text = "发送长度提示:" & Parms(0)
btnGameSelect1.Tag = "Hint|" & Parms(0)
btnGameSelect1.IsEnabled = True
btnGameSelect2.Text = "发送类别提示:" & Parms(1)
btnGameSelect2.Tag = "Hint|" & Parms(1)
btnGameSelect2.IsEnabled = True
End Sub)

Case "SelectClear"
'SelectClear:隐藏选题区
RunInUi(Sub() panChat.Margin = New Thickness(250, 130, 25, 25))

End Select
End Sub
Expand Down
47 changes: 30 additions & 17 deletions Server/formMain.xaml.vb
Original file line number Diff line number Diff line change
Expand Up @@ -828,23 +828,36 @@ Public Class formMain

Case "Select"
'Select(Integer 选择编号):选择某个题目编号
If u.SG.State = SGStates.Turning Then
'设置题目
u.Room.SG.Answer = u.Room.SG.Selections(Val(Parm))(0)
u.Room.SG.Hint = u.Room.SG.Selections(Val(Parm))(1)
'发送公告
For Each us As UserData In u.Room.Users
If us.SG.State = SGStates.Turning Then
us.Send("Chat|系统:你选择的题目为【" & u.Room.SG.Answer & "】。|True¨" &
"Content|请描述:" & u.Room.SG.Answer & "¨" &
"Select¨" &
"Chatable|True")
Else
us.Send("Chat|系统:本题共 " & u.Room.SG.Answer.Count & " 个字。|True¨" &
"Content|提示:" & u.Room.SG.Answer.Count & " 个字¨")
End If
Next
End If
If Not u.SG.State = SGStates.Turning Then Exit Sub
Dim Selection As Integer = Parm
'设置题目
u.Room.SG.Answer = u.Room.SG.Selections(Selection)(0)
u.Room.SG.Hint = u.Room.SG.Selections(Selection)(1)
u.Room.SG.Hinted = New List(Of String)
'发送公告
For Each us As UserData In u.Room.Users
If us.SG.State = SGStates.Turning Then
us.Send("Chat|系统:你选择的题目为【" & u.Room.SG.Answer & "】。|True¨" &
"Content|请描述:" & u.Room.SG.Answer & "¨" &
"Hint|" & u.Room.SG.Answer.Length & " 个字|" & u.Room.SG.Hint & "¨" &
"Chatable|True")
Else
us.Send("Content|正在描述")
End If
Next

Case "Hint"
'Hint(String 提示内容):对其余玩家发送提示
If Not u.SG.State = SGStates.Turning Then Exit Sub
u.Room.SG.Hinted.Add(Parm)
For Each us As UserData In u.Room.Users
If Parm.EndsWith("个字") Then
us.Send("Chat|提示:答案长度为【" & Parm & "】。|True")
Else
us.Send("Chat|提示:题目类别为【" & Parm & "】。|True")
End If
If Not us.SG.State = SGStates.Turning Then us.Send("Content|提示:" & Join(u.Room.SG.Hinted.ToArray, ","))
Next

End Select
End Sub
Expand Down
25 changes: 9 additions & 16 deletions Server/modSayGuess.vb
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,9 @@
''' </summary>
Public Timer As Integer = 99
''' <summary>
''' 是否已显示提示
''' 已显示的提示
''' </summary>
Public Hinted As Boolean = False
Public Hinted As New List(Of String)
End Class

#End Region
Expand Down Expand Up @@ -117,7 +117,7 @@
user.Send("Clear¨Game|你说我猜(旁观)¨" &
"Timer|" & user.Room.SG.Timer & "|" & If(user.Room.SG.EndWait, "Blue", If(user.Room.SG.CorrectCount = 0, "Orange", "Red")) & "¨" &
"Chatable|" & user.Room.SG.EndWait.ToString & "¨" &
"Select¨" &
"SelectClear¨" &
"Content|" & If(user.Room.SG.Answer = "",
If(user.Room.SG.EndWait, "描述者未选择题目", "等待描述者选择题目"),
If(user.Room.SG.EndWait, "题目:" & user.Room.SG.Answer, If(user.Room.SG.Timer <= 20, "提示:" & user.Room.SG.Answer.Count & " 个字," & user.Room.SG.Hint, "提示:" & user.Room.SG.Answer.Count & " 个字"))
Expand Down Expand Up @@ -338,7 +338,7 @@ NextPlayer:
room.SG.ScoreBase = room.GetGameUsers.Count - 1
room.SG.CorrectCount = 0
room.SG.EndWait = False
room.SG.Hinted = False
room.SG.Hinted = New List(Of String)
'获取题目
room.SG.Selections = New ArrayList From {SGGet(), SGGet()}
room.SG.Answer = ""
Expand All @@ -355,13 +355,13 @@ NextPlayer:
Case SGStates.Observe
us.Send("Chat|系统:由 " & player.Name & " 进行描述。|True¨" &
"Content|等待描述者选择题目¨" &
"Select¨" &
"SelectClear¨" &
"Timer|99|Orange¨" &
"Chatable|False")
Case SGStates.Failed
us.Send("Chat|系统:由 " & player.Name & " 进行描述。|True¨" &
"Content|等待描述者选择题目¨" &
"Select¨" &
"SelectClear¨" &
"Timer|99|Orange¨" &
"Chatable|True")
End Select
Expand All @@ -378,7 +378,7 @@ NextPlayer:
frmMain.BoardcastInRoom("Content|描述者未选择题目¨" &
"Chat|系统:描述者 " & room.SG.Turner.Name & " 未选择题目,本轮结束。|True¨" &
"Chatable|True¨" &
"Select", room)
"SelectClear", room)
room.SG.Timer = 5
Else
frmMain.BoardcastInRoom("Content|题目:" & room.SG.Answer, room)
Expand All @@ -399,7 +399,7 @@ NextPlayer:
room.SG.Turner.SG.Score += sc
frmMain.BoardcastInRoom(frmMain.BoardcastList(room), room)
End If
frmMain.BoardcastInRoom(chat & "|True¨Chatable|True¨Select", room)
frmMain.BoardcastInRoom(chat & "|True¨Chatable|True¨SelectClear", room)
End If
'设置尚未描述的玩家
Dim unturned As New ArrayList
Expand Down Expand Up @@ -433,14 +433,7 @@ NextPlayer:
SGTurnEnd(room)
End If
End If
If room.SG.Timer = 20 And Not room.SG.Hinted Then
'显示第二段提示
room.SG.Hinted = True
For Each us As formMain.UserData In room.Users
If us.SG.State = SGStates.Failed Or us.SG.State = SGStates.Observe Then us.Send("Chat|提示:题目类别为【" & room.SG.Hint & "】。|True")
If Not us.SG.State = SGStates.Turning Then us.Send("Content|提示:" & room.SG.Answer.Count & " 个字," & room.SG.Hint)
Next
ElseIf room.SG.Timer = 69 And room.SG.Answer = "" Then
If room.SG.Timer = 69 And room.SG.Answer = "" Then
'没有选择题目,强制结束
SGTurnEnd(room)
End If
Expand Down
5 changes: 4 additions & 1 deletion 指令表.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ Content String
Timer Integer ʱ��, String ��ɫ ���õ���ʱ
Observe Integer ���� ��ʾ�Թ�������
Chatable Boolean �Ƿ�������� ���û�ر�����
Select String? ѡ��1, String? ѡ��2 �ı�ѡ������ʾ��������ѡ�������޲���
Select String ѡ��1, String ѡ��2 �ı�ѡ������ʾ
Hint String ��ʾ1, String ��ʾ2 ��ѡ������ʾ��ʾѡ��
SelectClear ����ѡ����

�������� �����ָ� ��������

Expand All @@ -30,3 +32,4 @@ Prepare Boolean
Start ��ʼ��Ϸ
Kick String ����� �߳����
Select Integer ѡ���� ѡ��ij����Ŀ���
Hint String ��ʾ���� ��������ҷ�����ʾ

0 comments on commit 0d78ca0

Please sign in to comment.