2 bugs / farm and bandit
This commit is contained in:
@@ -62,13 +62,17 @@ async function autoBootcampLoop() {
|
|||||||
const isFavor = reward.power_id?.includes('favor');
|
const isFavor = reward.power_id?.includes('favor');
|
||||||
const stashable = reward.stashable;
|
const stashable = reward.stashable;
|
||||||
|
|
||||||
if (isInstant && !isFavor) {
|
const useReward = () => {
|
||||||
uw.gpAjax.ajaxPost('frontend_bridge', 'execute', {
|
uw.gpAjax.ajaxPost('frontend_bridge', 'execute', {
|
||||||
model_url: `PlayerAttackSpot/${player_id}`,
|
model_url: `PlayerAttackSpot/${player_id}`,
|
||||||
action_name: 'useReward',
|
action_name: 'useReward',
|
||||||
arguments: {}
|
arguments: {}
|
||||||
});
|
});
|
||||||
await botLog(player_id, world_id, 'bootcamp', 'Διεκδίκηση αμοιβής ληστών...');
|
botLog(player_id, world_id, 'bootcamp', `Reward used: ${reward.power_id}`);
|
||||||
|
};
|
||||||
|
|
||||||
|
if (isInstant && !isFavor) {
|
||||||
|
useReward();
|
||||||
} else if (stashable) {
|
} else if (stashable) {
|
||||||
uw.gpAjax.ajaxPost('frontend_bridge', 'execute', {
|
uw.gpAjax.ajaxPost('frontend_bridge', 'execute', {
|
||||||
model_url: `PlayerAttackSpot/${player_id}`,
|
model_url: `PlayerAttackSpot/${player_id}`,
|
||||||
@@ -78,22 +82,10 @@ async function autoBootcampLoop() {
|
|||||||
success: () => {
|
success: () => {
|
||||||
botLog(player_id, world_id, 'bootcamp', `Reward stashed: ${reward.power_id}`);
|
botLog(player_id, world_id, 'bootcamp', `Reward stashed: ${reward.power_id}`);
|
||||||
},
|
},
|
||||||
error: () => {
|
error: useReward
|
||||||
uw.gpAjax.ajaxPost('frontend_bridge', 'execute', {
|
|
||||||
model_url: `PlayerAttackSpot/${player_id}`,
|
|
||||||
action_name: 'useReward',
|
|
||||||
arguments: {}
|
|
||||||
});
|
|
||||||
botLog(player_id, world_id, 'bootcamp', 'Αποτυχία διεκδίκησης αμοιβής.');
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
uw.gpAjax.ajaxPost('frontend_bridge', 'execute', {
|
useReward();
|
||||||
model_url: `PlayerAttackSpot/${player_id}`,
|
|
||||||
action_name: 'useReward',
|
|
||||||
arguments: {}
|
|
||||||
});
|
|
||||||
await botLog(player_id, world_id, 'bootcamp', `Reward used (fallback): ${reward.power_id}`);
|
|
||||||
}
|
}
|
||||||
await sleep(randInt(3000, 7000));
|
await sleep(randInt(3000, 7000));
|
||||||
return; // Wait for next cycle to attack
|
return; // Wait for next cycle to attack
|
||||||
|
|||||||
@@ -185,7 +185,8 @@ async function autoFarmLoop() {
|
|||||||
if (allFull) {
|
if (allFull) {
|
||||||
log('⚠️ Auto-farm: ALL warehouses are full (>95%) — skipping loot this cycle');
|
log('⚠️ Auto-farm: ALL warehouses are full (>95%) — skipping loot this cycle');
|
||||||
try {
|
try {
|
||||||
await apiFetch(`${BASE_URL}/api/farm_status?player_id=${player_id}`, {
|
const world_id = uw.Game?.world_id || '';
|
||||||
|
await apiFetch(`${BASE_URL}/api/farm_status?player_id=${player_id}&world_id=${world_id}`, {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: { 'Content-Type': 'application/json' },
|
headers: { 'Content-Type': 'application/json' },
|
||||||
body: JSON.stringify({ warehouse_full: true })
|
body: JSON.stringify({ warehouse_full: true })
|
||||||
@@ -200,7 +201,8 @@ async function autoFarmLoop() {
|
|||||||
await executeFarmLoot({ payload: { loot_option: farmSettings.loot_option } });
|
await executeFarmLoot({ payload: { loot_option: farmSettings.loot_option } });
|
||||||
// Report success so dashboard shows last_farmed_at
|
// Report success so dashboard shows last_farmed_at
|
||||||
try {
|
try {
|
||||||
await apiFetch(`${BASE_URL}/api/farm_status?player_id=${player_id}`, {
|
const world_id = uw.Game?.world_id || '';
|
||||||
|
await apiFetch(`${BASE_URL}/api/farm_status?player_id=${player_id}&world_id=${world_id}`, {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: { 'Content-Type': 'application/json' },
|
headers: { 'Content-Type': 'application/json' },
|
||||||
body: JSON.stringify({ warehouse_full: false })
|
body: JSON.stringify({ warehouse_full: false })
|
||||||
|
|||||||
@@ -437,9 +437,12 @@ def upload_market_data():
|
|||||||
@api.route('/api/farm_status', methods=['POST', 'GET'])
|
@api.route('/api/farm_status', methods=['POST', 'GET'])
|
||||||
def farm_status():
|
def farm_status():
|
||||||
player_id = request.args.get('player_id')
|
player_id = request.args.get('player_id')
|
||||||
|
world_id = request.args.get('world_id')
|
||||||
if not player_id:
|
if not player_id:
|
||||||
return jsonify({'error': 'no player_id'}), 400
|
return jsonify({'error': 'no player_id'}), 400
|
||||||
kv_key = f'farm_status_{player_id}'
|
|
||||||
|
player_key = f"{player_id}_{world_id}" if world_id else player_id
|
||||||
|
kv_key = f'farm_status_{player_key}'
|
||||||
conn = get_db()
|
conn = get_db()
|
||||||
if request.method == 'POST':
|
if request.method == 'POST':
|
||||||
data = request.get_json(silent=True) or {}
|
data = request.get_json(silent=True) or {}
|
||||||
|
|||||||
Reference in New Issue
Block a user