private void UseSpecialAction(IClient client, IClient target, Specials special) { Log.Default.WriteLine(LogLevels.Debug, "Game {0}: UseSpecial[{1}][{2}]:{3}", Name, client.Name, target.Name, special); if (target.State != ClientStates.Playing) { Log.Default.WriteLine(LogLevels.Warning, "Cannot use special on a non-playing client"); return; } // Update statistics UpdateStatistics(client.Name, target.Name, special); // Store special id locally int specialId = _specialId; // Increment special _specialId++; // If special is Switch, call OnGridModified with switched grids if (special == Specials.SwitchFields) { // Switch locally byte[] tmp = target.Grid; target.Grid = client.Grid; client.Grid = tmp; // Send switched grid to player and target client.OnGridModified(client.Id, client.Grid); if (client != target) target.OnGridModified(target.Id, target.Grid); // Client and target will send their grid when receiving them (with an optional capping) } // Inform about special use foreach (IClient c in Clients) c.OnSpecialUsed(client.Id, target.Id, specialId, special); }