(rest string, user *users.UserRecord, room *rooms.Room, flags events.EventFlag)
| 78 | } |
| 79 | |
| 80 | func (c *CleanupModule) userTrashCommand(rest string, user *users.UserRecord, room *rooms.Room, flags events.EventFlag) (bool, error) { |
| 81 | |
| 82 | // Check whether the user has an item in their inventory that matches |
| 83 | matchItem, found := user.Character.FindInBackpack(rest) |
| 84 | |
| 85 | if !found { |
| 86 | user.SendText(fmt.Sprintf(`You don't have a "%s" to trash.`, rest)) |
| 87 | } else { |
| 88 | |
| 89 | c.loadConfig() |
| 90 | |
| 91 | isSneaking := user.Character.HasBuffFlag(buffs.Hidden) |
| 92 | |
| 93 | user.Character.RemoveItem(matchItem) |
| 94 | |
| 95 | events.AddToQueue(events.ItemOwnership{ |
| 96 | UserId: user.UserId, |
| 97 | Item: matchItem, |
| 98 | Gained: false, |
| 99 | }) |
| 100 | |
| 101 | user.SendText( |
| 102 | fmt.Sprintf(`You trash the <ansi fg="item">%s</ansi> for good.`, matchItem.DisplayName())) |
| 103 | |
| 104 | if !isSneaking { |
| 105 | room.SendText( |
| 106 | fmt.Sprintf(`<ansi fg="username">%s</ansi> destroys <ansi fg="item">%s</ansi>...`, user.Character.Name, matchItem.DisplayName()), |
| 107 | user.UserId) |
| 108 | } |
| 109 | |
| 110 | if c.DefaultTrashExperienceValue > 0 { |
| 111 | |
| 112 | // Grant experience equal to a tenth of the item value |
| 113 | iSpec := matchItem.GetSpec() |
| 114 | |
| 115 | xpGrant := int(float64(iSpec.Value) / 10) |
| 116 | if xpGrant < c.DefaultTrashExperienceValue { |
| 117 | xpGrant = c.DefaultTrashExperienceValue |
| 118 | } |
| 119 | user.GrantXP(xpGrant, `trash cleanup`) |
| 120 | |
| 121 | } |
| 122 | |
| 123 | } |
| 124 | |
| 125 | return true, nil |
| 126 | } |
| 127 | |
| 128 | func (c *CleanupModule) mobTrashCommand(rest string, mob *mobs.Mob, room *rooms.Room) (bool, error) { |
| 129 |
nothing calls this directly
no test coverage detected