Go:经济¶
函数¶
OnMoneyBefore¶
| Go | |
|---|---|
在每一笔经济交易之前调用 fn;返回 false 否决这笔交易。
- 参数:
- fn :
func(MoneyEvent) bool
- fn :
- 返回值类型:
error - 对应槽位:
money_listen_before_event
OnMoneyAfter¶
| Go | |
|---|---|
在每一笔经济交易之后调用 fn。
- 参数:
- fn :
func(MoneyEvent)
- fn :
- 返回值类型:
error - 对应槽位:
money_listen_after_event
Money¶
| Go | |
|---|---|
一个余额。读不出来(xuid 为空,或者没有经济后端)时宿主给出负数,这里把它作为错误返回:真实的余额不会是负数。
- 参数:
- xuid :
string
- xuid :
- 返回值类型:
(int64, error) - 对应槽位:
get_money
SetMoney¶
| Go | |
|---|---|
设置余额。
- 参数:
- xuid :
string - amount :
int64
- xuid :
- 返回值类型:
error - 对应槽位:
set_money
AddMoney¶
| Go | |
|---|---|
增加余额。
- 参数:
- xuid :
string - delta :
int64
- xuid :
- 返回值类型:
error - 对应槽位:
add_money
ReduceMoney¶
| Go | |
|---|---|
减少余额。
- 参数:
- xuid :
string - delta :
int64
- xuid :
- 返回值类型:
error - 对应槽位:
reduce_money
TransferMoney¶
| Go | |
|---|---|
在两个余额之间转移 value;收款方收到的是扣税后的金额。
- 参数:
- from :
string - to :
string - value :
int64 - note :
string
- from :
- 返回值类型:
error - 对应槽位:
trans_money
MoneyHistory¶
| Go | |
|---|---|
MoneyHistory 列出最近 seconds 秒的交易,每行一条。
- 参数:
- xuid :
string - seconds :
int32
- xuid :
- 返回值类型:
([]string, error) - 对应槽位:
money_get_hist
ClearMoneyHistory¶
| Go | |
|---|---|
ClearMoneyHistory 清除早于 seconds 秒的交易。
- 参数:
- seconds :
int32
- seconds :
- 返回值类型:
error - 对应槽位:
money_clear_hist
MoneyRanking¶
| Go | |
|---|---|
MoneyRanking 列出富豪榜的前几名,每行一条。
- 参数:
- top :
uint16
- top :
- 返回值类型:
([]string, error) - 对应槽位:
money_ranking
MoneyKind¶
| Go | |
|---|---|
一次经济事件做了什么,是 Money* 几种之一。超出这几种的值来自更新的经济后端;否决监听器应当拒绝它,不要去猜。
| 名称 | 值 | 说明 |
|---|---|---|
MoneySet |
0 |
|
MoneyAdd |
1 |
|
MoneyReduce |
2 |
|
MoneyTrans |
3 |
MoneyEvent¶
一笔经济交易。