Skip to content

Commit

Permalink
fix: button player should turn to next game when room settling
Browse files Browse the repository at this point in the history
  • Loading branch information
bbb169 committed Oct 22, 2023
1 parent 4b96735 commit b203d09
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
14 changes: 13 additions & 1 deletion src/pages/playRoom/component/waitingStart/index.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,19 @@
import { emitSocket } from '@/utils/api.js';
import { Button, Space } from 'antd';
import { startGame } from '../../api.js';
import { RoomInfo } from '../../type.js';

export default function WaitingStart ({ isButtonPosition, hasOtherPlayers }: { isButtonPosition: boolean, hasOtherPlayers: number }) {
export default function WaitingStart ({ isButtonPosition, hasOtherPlayers, room }: { isButtonPosition: boolean; hasOtherPlayers: number; room: RoomInfo}) {
if (room.statu === 'started') {
return <></>;
} else if (room.statu === 'settling') {
return isButtonPosition
? <Button type="primary" shape="round" danger onClick={() => {
emitSocket('turnToNextGame');
}}>开始下一轮</Button>
: <Button type="primary">{!isButtonPosition ? '请等待庄家开始游戏' : '请等待其它玩家加入'}</Button>;
}

return isButtonPosition && hasOtherPlayers
? <Space data-intro="选择要进行的游戏的规则">
<Button type="primary" shape="round" danger onClick={() => {
Expand Down
3 changes: 1 addition & 2 deletions src/pages/playRoom/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,7 @@ export function PlayRoom () {
</div>}
{!isEmpty(room?.publicCards) && <DemoCards data-intro="公共牌堆,随着轮次依次展示,所有牌均可拖动,但是有些不会改变牌的顺序" cards={room?.publicCards as CardType[]} />}
{/* starting game or waiting */}
{room && room.statu !== 'started' &&
<WaitingStart isButtonPosition={isButtonPosition} hasOtherPlayers= {otherPlayers.length}/>}
{room && <WaitingStart isButtonPosition={isButtonPosition} hasOtherPlayers= {otherPlayers.length} room={room}/>}
</div>
{/* foot place for myPlayer to show its own cards */}
<FootHolder key='footHolder'/>
Expand Down

0 comments on commit b203d09

Please sign in to comment.