This repository has been archived by the owner on Nov 30, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(farmer): exchange resources on TRADING POST > CARAVAN (#11)
- Loading branch information
Showing
5 changed files
with
110 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import random | ||
|
||
from lokbot.enum import * | ||
|
||
|
||
def get_resource_index_by_item_code(item_code): | ||
""" | ||
Returns the index of the item in the resource list | ||
[0, 1, 2, 3 ] | ||
[food, lumber, stone, gold] | ||
""" | ||
if (ITEM_CODE_FOOD_1K <= item_code <= ITEM_CODE_FOOD_10M) or (item_code == ITEM_CODE_FOOD): | ||
return 0 | ||
|
||
if (ITEM_CODE_LUMBER_1K <= item_code <= ITEM_CODE_LUMBER_10M) or (item_code == ITEM_CODE_LUMBER): | ||
return 1 | ||
|
||
if (ITEM_CODE_STONE_1K <= item_code <= ITEM_CODE_STONE_10M) or (item_code == ITEM_CODE_STONE): | ||
return 2 | ||
|
||
if (ITEM_CODE_GOLD_1K <= item_code <= ITEM_CODE_GOLD_10M) or (item_code == ITEM_CODE_GOLD): | ||
return 3 | ||
|
||
return -1 | ||
|
||
|
||
def run_functions_in_random_order(*funcs): | ||
functions = list(funcs) | ||
random.shuffle(functions) | ||
for func in functions: | ||
func() |