sendNotification

sendNotification

> 函数列表

向你发送一条通知。通知会在战斗结束时到达,与你的其他通知放在一起,并附有战斗链接;根据你在战斗类别中的设置,它也可能以推送通知或邮件的形式发送。通常最适合在 afterFight() 中调用(参见 战斗钩子),这时战斗结果已经确定。

每天最多 50 条,从午夜(巴黎时间)起计算你的所有战斗,包括测试战斗:之后的通知将被忽略。为了把这个额度留给正式战斗,可以用 getFightContext 检查战斗场景。标题和消息显示在一行中:换行会变成空格。

// 在战斗结束时自动调用
function afterFight() {
	// 不是测试战斗时才发送:每天的额度留给正式战斗
	if (getFightContext() != FIGHT_CONTEXT_TEST && isDead(getEntity())) {
		sendNotification('Defeat', 'Died on turn ' + getTurn() + ', ' + getAliveEnemiesCount() + ' enemy(ies) still standing')
	}
}
// 在战斗结束时自动调用
function afterFight() {
	// 不是测试战斗时才发送:每天的额度留给正式战斗
	if (Fight.context !== Fight.Context.TEST && Fight.me.dead) {
		System.sendNotification('Defeat', 'Died on turn ' + Fight.turn + ', ' + Fight.getAliveEnemiesCount() + ' enemy(ies) still standing')
	}
}

// 在 TypeScript 和 JavaScript 中,只有定义了 turn() 的 AI 才会调用钩子
function turn() {
	// ...
}
# 在战斗结束时自动调用
def afterFight():
	# 不是测试战斗时才发送:每天的额度留给正式战斗
	if Fight.context != Fight.Context.TEST and Fight.me.dead:
		System.sendNotification('Defeat', 'Died on turn ' + str(Fight.turn) + ', ' + str(Fight.getAliveEnemiesCount()) + ' enemy(ies) still standing')

# 在 Python 中,只有定义了 turn() 的 AI 才会调用钩子
def turn():
	pass
参数
返回值