Rename charge command to recharge
This commit is contained in:
		
							parent
							
								
									7272749614
								
							
						
					
					
						commit
						87af905bc8
					
				
					 7 changed files with 14 additions and 13 deletions
				
			
		|  | @ -10,8 +10,8 @@ const ( | |||
| 	// CommandRepair Will attempt to repair the rover with an inventory object | ||||
| 	CommandRepair = "repair" | ||||
| 
 | ||||
| 	// CommandCharge Will use one tick to charge the rover | ||||
| 	CommandCharge = "charge" | ||||
| 	// CommandRecharge Will use one tick to charge the rover | ||||
| 	CommandRecharge = "recharge" | ||||
| ) | ||||
| 
 | ||||
| // Command represends a single command to execute | ||||
|  |  | |||
|  | @ -33,7 +33,7 @@ func TestCommand_Move(t *testing.T) { | |||
| 	assert.Equal(t, pos, newPos, "Failed to correctly set position for rover") | ||||
| } | ||||
| 
 | ||||
| func TestCommand_Charge(t *testing.T) { | ||||
| func TestCommand_Recharge(t *testing.T) { | ||||
| 	world := NewWorld(8) | ||||
| 	a, err := world.SpawnRover() | ||||
| 	assert.NoError(t, err) | ||||
|  | @ -56,8 +56,8 @@ func TestCommand_Charge(t *testing.T) { | |||
| 	rover, _ := world.GetRover(a) | ||||
| 	assert.Equal(t, rover.MaximumCharge-1, rover.Charge) | ||||
| 
 | ||||
| 	chargeCommand := Command{Command: CommandCharge} | ||||
| 	assert.NoError(t, world.Enqueue(a, chargeCommand), "Failed to queue charge command") | ||||
| 	chargeCommand := Command{Command: CommandRecharge} | ||||
| 	assert.NoError(t, world.Enqueue(a, chargeCommand), "Failed to queue recharge command") | ||||
| 
 | ||||
| 	// Tick the world | ||||
| 	world.EnqueueAllIncoming() | ||||
|  |  | |||
|  | @ -134,8 +134,8 @@ func (w *World) GetRover(rover string) (Rover, error) { | |||
| 	return i, nil | ||||
| } | ||||
| 
 | ||||
| // ChargeRover charges up a rover | ||||
| func (w *World) ChargeRover(rover string) (int, error) { | ||||
| // RoverRecharge charges up a rover | ||||
| func (w *World) RoverRecharge(rover string) (int, error) { | ||||
| 	w.worldMutex.Lock() | ||||
| 	defer w.worldMutex.Unlock() | ||||
| 
 | ||||
|  | @ -371,7 +371,7 @@ func (w *World) Enqueue(rover string, commands ...Command) error { | |||
| 			} | ||||
| 		case CommandStash: | ||||
| 		case CommandRepair: | ||||
| 		case CommandCharge: | ||||
| 		case CommandRecharge: | ||||
| 			// Nothing to verify | ||||
| 		default: | ||||
| 			return fmt.Errorf("unknown command: %s", c.Command) | ||||
|  | @ -459,8 +459,8 @@ func (w *World) ExecuteCommand(c *Command, rover string) (err error) { | |||
| 			r.Integrity = r.Integrity + 1 | ||||
| 			w.Rovers[rover] = r | ||||
| 		} | ||||
| 	case CommandCharge: | ||||
| 		_, err := w.ChargeRover(rover) | ||||
| 	case CommandRecharge: | ||||
| 		_, err := w.RoverRecharge(rover) | ||||
| 		if err != nil { | ||||
| 			return err | ||||
| 		} | ||||
|  |  | |||
|  | @ -168,7 +168,7 @@ func TestWorld_RoverStash(t *testing.T) { | |||
| 
 | ||||
| 	// Recharge the rover | ||||
| 	for i := 0; i < rover.MaximumCharge; i++ { | ||||
| 		world.ChargeRover(a) | ||||
| 		world.RoverRecharge(a) | ||||
| 	} | ||||
| 
 | ||||
| 	// Place an object | ||||
|  |  | |||
|  | @ -43,6 +43,7 @@ type Command struct { | |||
| 	// "move" - Move the rover in a direction, requires bearing | ||||
| 	// "stash" - Stashes item at current location in rover inventory | ||||
| 	// "repair" - Repairs the rover using an inventory object | ||||
| 	// "recharge" - Waits a tick to add more charge to the rover | ||||
| 	Command string `protobuf:"bytes,1,opt,name=command,proto3" json:"command,omitempty"` | ||||
| 	// The bearing, example: NE | ||||
| 	Bearing string `protobuf:"bytes,2,opt,name=bearing,proto3" json:"bearing,omitempty"` | ||||
|  |  | |||
|  | @ -212,7 +212,7 @@ | |||
|       "properties": { | ||||
|         "command": { | ||||
|           "type": "string", | ||||
|           "title": "The command to execute\n\"move\" - Move the rover in a direction, requires bearing\n\"stash\" - Stashes item at current location in rover inventory\n\"repair\" - Repairs the rover using an inventory object" | ||||
|           "title": "The command to execute\n\"move\" - Move the rover in a direction, requires bearing\n\"stash\" - Stashes item at current location in rover inventory\n\"repair\" - Repairs the rover using an inventory object\n\"recharge\" - Waits a tick to add more charge to the rover" | ||||
|         }, | ||||
|         "bearing": { | ||||
|           "type": "string", | ||||
|  |  | |||
|  | @ -65,7 +65,7 @@ message Command { | |||
|     // "move" - Move the rover in a direction, requires bearing | ||||
|     // "stash" - Stashes item at current location in rover inventory | ||||
|     // "repair" - Repairs the rover using an inventory object | ||||
|     // "charge" - Waits a tick to add more charge to the rover | ||||
|     // "recharge" - Waits a tick to add more charge to the rover | ||||
|     string command = 1; | ||||
| 
 | ||||
|     // The bearing, example: NE | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue