本文整理汇总了Golang中MonsterQuest/gameObjectsBase.Itemer.GetKindId方法的典型用法代码示例。如果您正苦于以下问题:Golang Itemer.GetKindId方法的具体用法?Golang Itemer.GetKindId怎么用?Golang Itemer.GetKindId使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MonsterQuest/gameObjectsBase.Itemer
的用法示例。
在下文中一共展示了Itemer.GetKindId方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: Equip
func (p *Player) Equip(item gameObjectsBase.Itemer, slotIota int) (int, consts.JsonType) {
var res consts.JsonType = nil
slot := p.slots[slotIota]
if slot == nil || !slot.isSuitableType(item.GetItemType()) {
return consts.BADSLOT, res
}
if item.GetItemClass() != consts.ITEM_CLASS_GARMENT || p.Equipped(item) {
return consts.BADID, res
}
p.Unequip(slotIota)
db := connect.CreateConnect()
_, err := db.Exec("CALL equip_item(?, ?, ?, ?)", p.DBId, item.GetKindId(), item.EquipItem(p.Inventory), slotIota)
if err == nil {
if ok, s := p.getNearbySlot(slotIota, item.GetItemSubtype()); ok {
if p.slots[s].item != nil && p.slots[s].item.GetID() != item.GetID() {
p.Unequip(s)
}
res = consts.JsonType{}
res[consts.SlotNameMapping[s]] = item.GetID()
p.slots[s].item = nil
} else {
p.Unequip(slotIota)
}
slot.item = item
}
if err == nil {
return consts.OK, res
} else {
return consts.BADID, res
}
}
示例2: DropItem
func (p *Player) DropItem(item gameObjectsBase.Itemer, amount int) (int, gameObjectsBase.Itemer) {
db := connect.CreateConnect()
place, new_item := p.ActiveObject.DropItem(item, amount)
if s := p.getSlotByItem(item); s != consts.SLOT_DEFAULT {
if item.GetAmount()-amount <= 0 {
p.slots[s].item = nil
}
db.Exec("CALL dec_user_slot_amount(?, ?, ?, ?)", p.DBId, item.GetKindId(), s, amount)
} else {
db.Exec("CALL dec_user_item_amount(?, ?, ?, ?)", p.DBId, item.GetKindId(), place, amount)
}
return place, new_item
}
示例3: PickUpItem
func (p *Player) PickUpItem(item gameObjectsBase.Itemer) (bool, gameObjectsBase.Itemer) {
var err error = nil
db := connect.CreateConnect()
place, i := p.AddItem(item)
if item.IsHeapItem() && place == -1 {
_, err = db.Exec("CALL inc_user_slot_amount(?, ?, ?, ?)", p.DBId, item.GetKindId(), p.getSlotByItemType(item.GetItemType()), item.GetAmount())
} else {
_, err = db.Exec("CALL inc_user_item_amount(?, ?, ?, ?)", p.DBId, item.GetKindId(), place, item.GetAmount())
}
if err != nil {
//
fmt.Println(err)
}
return err == nil, i
}
示例4: DeleteItem
func (p *Player) DeleteItem(item gameObjectsBase.Itemer, amount int) (bool, gameObjectsBase.Itemer) {
var (
i gameObjectsBase.Itemer = item
res bool = false
)
db := connect.CreateConnect()
var place int
place, i = p.Inventory.DeleteItem(item, amount)
if s := p.getSlotByItem(item); s != consts.SLOT_DEFAULT {
if item.GetAmount() <= 0 {
p.slots[s].item = nil
i = nil
}
_, err := db.Exec("CALL dec_user_slot_amount(?, ?, ?, ?)", p.DBId, item.GetKindId(), s, amount)
res = err == nil
} else {
_, err := db.Exec("CALL dec_user_item_amount(?, ?, ?, ?)", p.DBId, item.GetKindId(), place, amount)
res = err == nil
}
return res, i
}