Changeset b72b78844ce1632d3f525227861f9c64dffaf5de


Ignore:
Timestamp:
08/08/09 17:43:10 (3 years ago)
Author:
Flupke <luper.rouch@…>
Children:
867160cce99744a7e64db9ac0de6bb741ada3087
Parents:
df6b2f294e72732aa332cc603206dec1576c9577, a59347fe3cc3a7fb05360bf2952952fb9cf01d28
git-committer:
Flupke <luper.rouch@…> (08/08/09 17:43:10)
Message:

Merge branch 'master' of luper.fr:/var/git/projects

Files:
2 added
1 edited

Legend:

Unmodified
Added
Removed
  • wow/CashControl/CashControl.lua

    r7d3bd04 ra59347f  
    5454            type = "input", 
    5555            name = "fixedcost", 
    56             desc = "Specify the fixed cost of components needed for a recipe: /cc fixed [recipe index] [[x]g] [[y]s] [[z]c]", 
     56            desc = "Specify the fixed cost of components needed for a recipe: /cc fixedcost [recipe index] [[x]g] [[y]s] [[z]c]", 
    5757            set = "SetRecipeFixedCost", 
    58         }, 
    59         numitems = { 
    60             type = "input", 
    61             name = "numitems", 
    62             desc = "Specify the number of items produced by a recipe: /cc numitems [recipe index] [num items] (default: 1)", 
    63             set = "SetRecipeNumItems", 
    6458        }, 
    6559        reset = { 
    6660            type = "execute", 
    6761            name = "reset", 
    68             desc = "Reset database", 
     62            desc = "Reset database - All recipes and history is lost, this cannot be undone !", 
    6963            func = "Reset", 
    7064        }, 
     
    128122 
    129123function CashControl:OnEnable() 
    130     CashControl:Print("CashControl loaded, type /cc or /cashinfo for info") 
     124    CashControl:Print("CashControl loaded, type /cc or /cashcontrol for info") 
    131125end 
    132126 
     
    149143    count = tonumber(count) 
    150144    local cost = self:ParseMoneyString(cost_string) 
     145    if cost == nil then 
     146        CashControl:Print("Invalid money string: ", cost_string) 
     147        return 
     148    end 
    151149    local reagent_name = db.reagents[reagent_index] 
    152150    if reagent_name == nil then 
     
    193191    CashControl:Print("Minimum prices:") 
    194192    for recipe_name, info in pairs(db.craft_stock) do 
    195         CashControl:Print(string.format("%s: %s", recipe_name,  
    196             GetCoinTextureString(info.cost / info.count))) 
     193        local base_price = info.cost / info.count 
     194        local ah_cut = base_price * 5 / 100 
     195        local price = base_price + ah_cut 
     196        CashControl:Print(string.format("%s: %s (+5%% cut: %s)",  
     197                    recipe_name,  
     198                    GetCoinTextureString(price), 
     199                    GetCoinTextureString(ah_cut) 
     200                ) 
     201            ) 
    197202    end 
    198203end 
     
    317322end 
    318323 
    319 function CashControl:SetRecipeNumItems(info, input) 
    320     local db = self.db.factionrealm 
    321     local i1, i2, recipe_index, count = string.find(input, "^ *(%d+) +(%d+) *$") 
    322     if i1 == nil then 
    323         CashControl:Print(string.format("You must specify a recipe index and an items count: /cc numitems [recipe index] [count]")) 
    324         return 
    325     end 
    326     recipe_index = tonumber(recipe_index) 
    327     count = tonumber(count) 
    328     local recipe_name = db.recipes[recipe_index] 
    329     db.recipes_specs[recipe_name].num_items = count 
    330     CashControl:Print(string.format("%s produces %d items", recipe_name,  
    331         count)) 
    332 end 
    333  
    334324function CashControl:Reset() 
    335325    -- Reset database to defaults 
     
    388378    -- 
    389379    local db = self.db.factionrealm 
    390     local i1, i2, recipe_index, cost = string.find(input, "^ *(%d+) +(.+)$") 
     380    local i1, i2, recipe_index, cost_string = string.find(input, "^ *(%d+) +(.+)$") 
    391381    if i1 == nil then 
    392382        CashControl:Print(string.format( 
     
    395385    end 
    396386    recipe_index = tonumber(recipe_index) 
    397     cost = self:ParseMoneyString(cost) 
     387    local cost = self:ParseMoneyString(cost_string) 
    398388    if cost == nil then 
     389        CashControl:Print("Invalid money string: ", cost_string) 
    399390        return 
    400391    end 
     
    421412    CashControl:Print("    Recipe:") 
    422413    for reagent, count in pairs(specs.comps) do 
    423         CashControl:Print(string.format("        %s*%d", reagent, count)) 
    424     end 
    425     CashControl:Print("    Items per craft: "..specs.num_items) 
     414        CashControl:Print(string.format("        %s x %d", reagent, count)) 
     415    end 
    426416    CashControl:Print("    Fixed cost: "..GetCoinTextureString(specs.fixed_cost)) 
    427417end 
     
    438428            comps = {}, 
    439429            fixed_cost = 0, 
    440             num_items = 1, 
    441430        } 
    442431    end 
     
    548537        local stock = db.stock[reagent] 
    549538        local needed_count = count 
    550         CashControl:Print("taking", count, reagent, "for", recipe_name) 
     539        -- CashControl:Print("taking", count, reagent, "for", recipe_name) 
    551540        while needed_count ~= 0 and #stock ~= 0 do  
    552541            if stock[1].count <= needed_count then 
    553542                -- Fully remove this stock entry 
    554543                local stock_entry = table.remove(stock, 1) 
    555                 CashControl:Print("full", stock_entry.cost, stock_entry.count) 
     544                --CashControl:Print("full", stock_entry.cost, stock_entry.count) 
    556545                cost = cost + stock_entry.cost 
    557546                needed_count = needed_count - stock_entry.count 
     
    562551                stock[1].count = stock[1].count - needed_count 
    563552                stock[1].cost = stock[1].cost - taken_cost 
    564                 CashControl:Print("partial", taken_cost, needed_count) 
     553                --CashControl:Print("partial", taken_cost, needed_count) 
    565554                cost = cost + taken_cost 
    566555                needed_count = 0 
    567556            end 
    568557        end 
    569         CashControl:Print("finished taking", count, #stock) 
     558        --CashControl:Print("finished taking", count, #stock) 
    570559        if needed_count ~= 0 then 
    571560            CashControl:Print(string.format( 
Note: See TracChangeset for help on using the changeset viewer.