BibliothecaDAO / realms-contracts

Realms Monorepo for Ethereum contracts and Starknet contracts.
https://bibliothecadao.xyz/
MIT License
87 stars 33 forks source link

Armies reset to home realm after traveling #267

Closed Psyclonic closed 1 year ago

Psyclonic commented 1 year ago

Problem Summary: After raiding (or maybe anytime traveling is finished), army resets to "home realm".

Expected: Army can raid a realm and then raid nearby realms, without having to travel from home again.


Here's what I think is happening:

Instead, either coordinates should be set on the army after travel is complete (in the raid or next travel command?), or the travel information should indicate the army's position after travel. This probably makes most sense for moving objects (like armies) since they should have a travel information set all the time (either they are traveling, or they have arrived and are thus past the travel time for their most recent travel information).

ponderingdemocritus commented 1 year ago

I think we need to set the coordinates in that statement

like:

    // if no current location set, use the home coordinates
    if (traveller_coordinates.x == 0) {
        coordinates.write(
            traveller_contract_id, traveller_token_id, traveller_nested_id, destination_coordinates
        );
        let (traveller_coordinates: Point) = get_coordinates(
            traveller_contract_id, traveller_token_id, 0
        );
        tempvar traveller_coordinates = traveller_coordinates;
        tempvar syscall_ptr = syscall_ptr;
        tempvar range_check_ptr = range_check_ptr;
        tempvar pedersen_ptr = pedersen_ptr;
    } else {
        tempvar traveller_coordinates = traveller_coordinates;
        tempvar syscall_ptr = syscall_ptr;
        tempvar range_check_ptr = range_check_ptr;
        tempvar pedersen_ptr = pedersen_ptr;
    }

So we can just set the destination in the first call - then they will have that destination when they travel again