* * Role Permissions: * build (All) */
(rest string, user *users.UserRecord, room *rooms.Room, flags events.EventFlag)
| 18 | * build (All) |
| 19 | */ |
| 20 | func Build(rest string, user *users.UserRecord, room *rooms.Room, flags events.EventFlag) (bool, error) { |
| 21 | |
| 22 | // args should look like one of the following: |
| 23 | // info <optional room id> |
| 24 | // <move to room id> |
| 25 | args := util.SplitButRespectQuotes(rest) |
| 26 | |
| 27 | if len(args) < 2 { |
| 28 | // send some sort of help info? |
| 29 | infoOutput, _ := templates.Process("admincommands/help/command.build", nil, user.UserId, user.UserId) |
| 30 | user.SendText(infoOutput) |
| 31 | } else { |
| 32 | |
| 33 | // #build zone "The Arctic" |
| 34 | if args[0] == "zone" { |
| 35 | |
| 36 | zoneName := strings.Join(args[1:], ` `) |
| 37 | |
| 38 | if roomId, err := rooms.CreateZone(zoneName); err != nil { |
| 39 | user.SendText(err.Error()) |
| 40 | } else { |
| 41 | user.SendText(fmt.Sprintf("Zone %s created.", zoneName)) |
| 42 | |
| 43 | if err := rooms.MoveToRoom(user.UserId, roomId); err != nil { |
| 44 | user.SendText(err.Error()) |
| 45 | } else { |
| 46 | user.SendText(fmt.Sprintf("Moved to room %d.", roomId)) |
| 47 | events.AddToQueue(events.Input{ |
| 48 | UserId: user.UserId, |
| 49 | InputText: `look`, |
| 50 | }, -1) |
| 51 | } |
| 52 | } |
| 53 | } |
| 54 | |
| 55 | // build room north <south> |
| 56 | // build room north-x2 <south-x2> |
| 57 | // build room attic:up <down> |
| 58 | if args[0] == "room" { |
| 59 | |
| 60 | var err error |
| 61 | |
| 62 | // Prep exit parts of command |
| 63 | // There are special exit names (defined in internal/mapper/mapper.go ) that |
| 64 | // translate to compass directions such as east-x3 (east 3 "room spaces" away) |
| 65 | // exit names can be freeform, but if they are to show up on a map they must have |
| 66 | // a compass direction. This can be achieved by appending ":direction" to an exit name |
| 67 | // such as: "attic:up" or "zipline:east-x3" |
| 68 | exitName := args[1] |
| 69 | exitDirection := exitName // A special exit name that corresponds to special distances |
| 70 | returnExitName := `` |
| 71 | returnExitDirection := `` |
| 72 | |
| 73 | if exitName, exitDirection, err = mapper.AdjustExitName(exitName); err != nil { |
| 74 | user.SendText(err.Error()) |
| 75 | return true, err |
| 76 | } |
| 77 |
nothing calls this directly
no test coverage detected