Example #1
0
void CRoom::_PutBlock(CPlayer *player, s32 blockid, s32 column)
{
	SG_ASSERT( player != NULL );

	if( player->PutBlock( blockid, column ) )
	{
		_NotifyPutBlock( player, blockid, column );
	}
	else
	{
		PlayerLost( player );
	}
}
Example #2
0
void CRoom::PlayerForceLeave(CPlayer *player)
{
	SG_ASSERT( player != NULL );
	SG_ASSERT( player->GetRoom() == this );
	SG_ASSERT( PlayerInRoom(player) );
	SG_ASSERT( m_pStateMachine != NULL );

	SERVER_LOG_DEBUG( "player:" << player->UserId().c_str() << " force leave" );

	if( m_pStateMachine->CurState() == E_RoomState_InGame )
	{
		SERVER_LOG_DEBUG( "player:" << player->UserId().c_str() << " force leave, game over" );

		SG_ASSERT( player->CurState() == E_PlayerState_InGame );
		PlayerLost( player );
	}

	CRoomBase::PlayerLeave( player );
}
Example #3
0
File: game.c Project: docwhat/cwimp
/* Score all the points for this roll */
void ScoreRoll(Int x) {
  Short aCounting[7];
  Short P1 = 0;
  Short P2 = 0;
  Short BlackDieValue = 0;
  Boolean FS;

  // Init vars
  stor.scorethisroll = 0;
  // FS will only be true if die 0 isn't kept
  // and it's value is FlamingSun
  FS = false;

  // Zero the counting array
  for ( x = 0 ; x < 7 ; x++ ) {
    aCounting[x] = 0;
  }

  // Fill the counting array
  for ( x = 0 ; x < NumCubes ; x++ ) {
    if ( !stor.cube[x].keep ) {
      if ( x == 0 &&
	   stor.cube[x].value == FlamingSun ) {
	FS = true;
      } else {
	// We found a die of value
	aCounting[ stor.cube[x].value ]++;
      } // If it's the FlamingSun
    } // If it's not kept
  }

  // Futtless
  // We are FUTTLESS, must clear flash
  if ( stor.flash ) {
    if ( aCounting[stor.flash] == 0 ) {
      // Clear the flash
      stor.flash = 0;
    } else {
      // No score - Turn on buttons again
      for( x = 0; x < NumCubes; x++ ) {
        if( stor.cube[x].value == stor.flash ) {
          EQAdd( CrossCube, x );
        }
      }
      EQAdd( ShowButtons, (Int)true );
      return;
    }
  }

  /**  Freight Train  **/
  // If a value in our counting array is equal to NumCubes,
  // then we have a freight train. Which cube we use doesn't
  // matter, if all are the same.
  if ( aCounting[ stor.cube[1].value ] == NumCubes ) {
    x = stor.cube[1].value;
    if ( x == 1 ) {
      PlayerLost( stor.currplayer, SuperNovaString );
      return;
    }
    if ( x == 6 ) {
      // ToDo: Say why player won
      PlayerWon();
      return;
    }
    
    AddScore( x * 100 );
    stor.YMNWTBYM = true;
    SetFlag( flag_FreightTrain, true );
    for ( x = 0 ; x < NumCubes ; x++ ) 
      stor.cube[x].keep = true;
  } else {
    // Look for Flashes (round one, no FlamingSuns)
    for ( x = 1 ; x <= 6 ; x++ ) {
      if ( aCounting[x] >= 3 ) {
        stor.flash = x;
      }
    }
	  
    // Fill P1 & P2
    if ( FS && !stor.flash ) {
      // Look for pairs
      for ( x = 1 ; x <= 6 ; x++ ) {
        if ( aCounting[x] == 2 ) {
          if ( !P1 )
            P1 = x;
	else
	  P2 = x;
        }
      } 

      // Do we have any pairs to go with our FS?
      if ( P2 ) {
        Int  die;
        
        DrawCurrScore(); /* So the player knows the score */
        die = DialogChooseTwo( PickFlashString, P1, P2 );
        
        aCounting[die]++;
        BlackDieValue = die;
        stor.cube[0].value = die;
      } else if ( P1 ) {
        // No choice. Flaming Sun *must* finish the Flash.
        aCounting[P1]++;
        BlackDieValue = P1;
        stor.cube[0].value = P1;
      }
      
      // Look for Flashes (round two, with FlamingSuns)
      for ( x = 1 ; x <= 6 ; x++ ) {
        if ( aCounting[x] == 3 ) {
          stor.flash = x;
        }
      }
    } /* If !FreightTrain */
  } /* If FlamingSun */
  


  // Flash Post; Score Calculation
  if ( stor.flash ) {
    int count;
    aCounting[stor.flash] -= 3;

    /* We decrement thru the Cubes */
    count = 0;
    x = NumCubes - 1;
    if ( P1 || P2 ) {
      // We've used a FlamingSun to
      // complete a Flash
      stor.cube[0].keep = true;
      count++;

    }
    for ( ; x >= 0 && count < 3 ; x-- ) {
      if ( !stor.cube[x].keep &&
	   stor.cube[x].value == stor.flash ) {
	// We found a cube matching the type of Flash
	stor.cube[x].keep = true;
	count++;
      }
    }
    if ( stor.flash == 1 )
      AddScore(100);
    else
      AddScore(stor.flash*10);
  }  
  
  // Clean Up Score

  // This is run twice (see below...)
  // Interate through the cubes...
  for( x = 0 ; x < NumCubes ; x++ ) {
    // If the cube isn't kept
    if ( !stor.cube[x].keep ) {
      if ( stor.cube[x].value == 1 ) {
	stor.cube[x].keep = true;
	AddScore(10);
      }
      if ( stor.cube[x].value == 5 ) {
	stor.cube[x].keep = true;
	AddScore(5);
      }
    }
  }

  // Fill in the Black Die's Flaming Sun
  // if it wasn't used above (in P1 && P2)
  if ( FS && !stor.cube[0].keep ) {
    if ( stor.scorethisroll == 0 ) {
      Int die;

      DrawCurrScore(); /* Player has to know the score */
      die = DialogChooseTwo( PickScoreString, 1, 5 );

      aCounting[die]++;
      BlackDieValue = die;
      stor.cube[0].value = die;
    } else {
      Int die;

      DrawCurrScore(); /* Player has to know the score */
      die = DialogChooseThree( PickNonScoreString, 1, 5, 0 );
      if( die == 0 ) die = 2;

      if( die != 2 ) {
	aCounting[die]++;
	BlackDieValue = die;
	stor.cube[0].value = die;
      }
    }
  }


  // Interate through the cubes...
  for( x = 0 ; x < NumCubes ; x++ ) {
    // If the cube isn't kept
    if ( !stor.cube[x].keep ) {
      if ( stor.cube[x].value == 1 ) {
	stor.cube[x].keep = true;
	AddScore(10);
      }
      if ( stor.cube[x].value == 5 ) {
	stor.cube[x].keep = true;
	AddScore(5);
      }
    }
  }

  /* nTrainWreck rule */
  if( stor.flags & flag_nTW  ) {
    Boolean bool = true;
    for( x = 0 ; x < NumCubes ; x++ ) {
      if ( stor.cube[x].keep ) {
	bool = false; // Whups, not a trainwreck
	break;
      }
    }