courgette/b3-plugin-poweradminbf3 — Issue #14: sort out level issues with !changeteam and !swap
Author: courgette
Created: 2011-11-06 10:17:51+00:00
State: open

See http://forum.bigbrotherbot.net/bf3b3-beta-board/poweradmin-bf3/msg30078/#msg30078

# Test cases

### case 1
Let say
- player Ryan is of level `40` _Admin_
- player Spoon is of level `40` _Admin_
Then
- Ryan should be able to `!swap Spoon`
- Spoon should be able to `!swap Ryan`

### case 2
Let say
- player Ryan is of level `40` _Admin_
- player Joe is of level `1` _User_
Then
- Ryan should be able to `!swap Joe`

### case 3
Let say
- player God is of level `100` _Super Admin_
- player Luck is of level `100` _Super Admin_
Then
- God should be able to `!swap Luck`
- Luck should be able to `!swap God`

# Supposed fix

```python
# check if client A and client B are in lower or equal groups
if client.maxLevel < sclientA.maxLevel:
if sclientA.maxGroup:
client.message(self.getMessage('operation_denied_level', {'name': sclientA.name, 'group': sclientA.maxGroup.name}))
else:
client.message(self.getMessage('operation_denied'))
return
if client.maxLevel < sclientB.maxLevel:
if sclientB.maxGroup:
client.message(self.getMessage('operation_denied_level', {'name': sclientB.name, 'group': sclientB.maxGroup.name}))
else:
client.message(self.getMessage('operation_denied'))
return
```
should be

```python
# check if client A and client B are in lower or equal groups
if client not sclientA and client.maxLevel <= sclientA.maxLevel:
if sclientA.maxGroup:
client.message(self.getMessage('operation_denied_level', {'name': sclientA.name, 'group': sclientA.maxGroup.name}))
else:
client.message(self.getMessage('operation_denied'))
return
if client not sclientB and client.maxLevel <= sclientB.maxLevel:
if sclientB.maxGroup:
client.message(self.getMessage('operation_denied_level', {'name': sclientB.name, 'group': sclientB.maxGroup.name}))
else:
client.message(self.getMessage('operation_denied'))
return
```