//! Behavior trees for the Baker family
//!
//! These are referenced by schedule blocks via the action: field

// Main baking work routine
behavior BakingWork {
    then {
        check_orders
        prepare_ingredients
        choose {
            make_bread
            make_pastries
            make_cakes
        }
        bake
        cool_products
        package_goods
    }
}

// Kitchen prep routine
behavior PrepKitchen {
    then {
        clean_surfaces
        check_supplies
        preheat_ovens
        organize_workspace
    }
}

// type
concept Vendor

// type
sub_concept VendorInventory {
    Bread: any,
    Pastries: any,
    Cakes: any,
    Cup: any
}

// type (but really just an enum lol)
concept Cup

// enum
sub_concept CupSize {
    Small,
    Medium,
    Large
}

// enum
sub_concept CupType {
    Ceramic,
    Glass,
    Plastic
}

// enum
sub_concept CupColor {
    Red,
    Blue,
    Green
}

// enum comparison done at compile time
concept_comparison CustomerInterestInCups {
    Interested: {
        CupSize: any, // any means any value of the type can be matched
        CupType: CupType is Glass or CupType is Plastic,
        CupColor: CupColor is Red or CupColor is Blue
    },
    NotInterested: {
        CupSize: any,
        CupType: any,
        CupColor: any
    },
    Maybe: {
        CupSize: any,
        CupType: any,
        CupColor: any
    }
}

// type
concept Plate

// enum
sub_concept PlateColor {
    Blue,
    Green,
    Red
}

// type
concept Customer

// enum
sub_concept CustomerInterest {
    Interested: 10,
    NotInterested: 20,
    Maybe: 70
}


// Market day selling behavior
behavior SellAtMarket {
    repeat {
        then {
            greet_customer
            show_products
            if(CustomerInterestInCups.Interested.CupSize is Medium or CupSize is Large and CustomerInterestInCups.Interested.CupType is Glass or CupType is Plastic and CustomerInterestInCups.Interested.CupColor is Red or CupColor is Blue) {
                make_sale(Cup)
            }
            if(CustomerInterestInCups.Interested.CupSize is Small and CustomerInterestInCups.Interested.CupType is Ceramic and CustomerInterestInCups.Interested.CupColor is Green) {
                if (Plate.PlateColor is Blue or PlateColor is Green) {
                    // variadic arguments
                    make_sale(Cup, Plate)
                }
            }
            // or there can be generic fallthroughs too
            thank_customer
        }
    }
}

// Assistant work (subset of main baking)
behavior AssistWithBaking {
    then {
        check_orders
        prepare_ingredients
        choose {
            assist_with_bread
            assist_with_pastries
        }
        clean_workspace
    }
}

// Quick morning prep
behavior QuickPrep {
    then {
        check_supplies
        organize_workspace
    }
}

concept Hunger

sub_concept HungerState {
    Hungry,
    NotHungry
}

// Basic needs (from Person template)
behavior BasicNeeds {
    repeat {
        choose {
            if(HungryState.Hungry) { eat }
            if(HungryState.NotHungry) { rest }
            if(thirsty) { drink }
        }
    }
}

// Social interaction
behavior SocialInteraction {
    choose {
        greet_neighbors
        chat_with_customers
        family_time
    }
}

// Baking skills
behavior BakingSkills {
    then {
        assess_dough
        adjust_recipe
        monitor_temperature
    }
}

// Customer service
behavior CustomerService {
    then {
        greet_warmly
        listen_to_needs
        recommend_products
        handle_payment
    }
}

// Child behaviors
behavior PlayBehavior {
    choose {
        play_outside
        play_with_toys
        draw_pictures
    }
}

behavior LearnBehavior {
    then {
        attend_school
        do_homework
        read_books
    }
}
