{-# LANGUAGE TupleSections #-}
module Dodge.Combine.Combinations where
--import Geometry
import Dodge.Data
--import Dodge.WorldEvent.SpawnParticle
--import Dodge.Particle.HitEffect.ExpireAndDamage
--import Dodge.Particle.Damage
import Dodge.Item.Equipment
import Dodge.Item.Craftable
import Dodge.Item.Weapon
--import Dodge.Combine.Module
--import Dodge.Base
import LensHelp

--import Data.Maybe

itemCombinations :: [([(IcAmount,ItemBaseType)],Item)]
itemCombinations =
    [ po [CRAFT PIPE, CRAFT HARDWARE]             (bangStick 1)
    , po [BANGSTICK 1, CRAFT TIN]         pistol
    , po [PISTOL, CRAFT SPRING, cr HARDWARE] autoPistol
    , po [AUTOPISTOL, cr PLANK, cr HARDWARE] smg
    , po [AUTOPISTOL, cr HARDWARE] machinePistol
    , po [BANGSTICK 1,cr CAN] revolver
    , po [REVOLVER, cr SPRING, cr HARDWARE] $ revolverX 1

    , po [cr TUBE,cr HARDWARE] bangCone
    , po [BANGCONE,cr PLANK] blunderbuss
    , po [BLUNDERBUSS,cr TUBE] bigBlunderbuss
    , po [BIGBLUNDERBUSS,cr TUBE] biggerBlunderbuss
    , po [BIGGERBLUNDERBUSS,cr TUBE] biggestBlunderbuss
--    , po [BANGCONE,PUMP,HARDWARE] $ grenadeLauncher 1
--    , po [GRENADELAUNCHER 1,MOTOR,DRUM] $ grenadeLauncher 2

    , p [p 2 $ cr PIPE,o $ cr HARDWARE] bangCane
    , p [p 2 $ cr PIPE,o BANGCANE] (bangCaneX 2)
    , po [BANGCANE,cr TIN] rifle
    , po [RIFLE,cr PLANK]  repeater
    , po [REPEATER,cr SPRING,cr HARDWARE] autoRifle
    , po [REPEATER,cr SPRING,cr CAN] burstRifle
    , po [BURSTRIFLE,cr SPRING,cr HARDWARE] fastBurstRifle
    , po [FASTBURSTRIFLE,cr SPRING,cr HARDWARE] completeBurstRifle
    , po [cr MOTOR,BANGCANEX 3] $ miniGunX 3
    , po [cr MOTOR,BANGCANEX 4] $ miniGunX 4
    , po [cr MOTOR,BANGCANEX 5] $ miniGunX 5
    , po [cr MOTOR,BANGCANEX 6] $ miniGunX 6

    , p [p 3 $ cr PIPE,o $ cr HARDWARE] bangRod
    , po [BANGROD,cr PLANK,cr HARDWARE]  elephantGun
    , po [ELEPHANTGUN,cr HARDWARE,cr PRISM] sniperRifle
    , po [ELEPHANTGUN,cr HARDWARE,cr TIN] amr
    , po [AMR,cr HARDWARE,cr SPRING] autoAmr
    , po [BANGROD,cr PLATE,cr DRUM,cr MOTOR] machineGun

    , p [p 2 $ cr TUBE,o $ cr HARDWARE] launcher
    , p [p 2 $ cr TUBE,o LAUNCHER] (launcherX 2)
    ] ++ [ p [p 2 $ cr TUBE,o $ LAUNCHERX i] (launcherX (i+1)) | i <- [2..9]]
    ++
    [ po [cr LIGHTER,cr PUMP,cr CAN]  flameSpitter
    , po [FLAMESPITTER,cr CAN,cr PUMP] blowTorch
    , po [FLAMESPITTER,cr DRUM] flameThrower
    , po [FLAMETHROWER,cr DRUM] flameWall
    , po [FLAMETHROWER,cr PUMP] flameTorrent

    , p [o $ cr PRISM,o $ cr TRANSFORMER,o $ cr PIPE] lasGun
    , p [o LASGUN,o $ cr PRISM] lasSway
    , p [o LASGUN,o $ cr HARDWARE] lasSwing
--    , p [o LASGUN,o PIPE] lasGunPulse
    , p [o LASGUN,p 2 $ cr PIPE] lasDual
    , p [o LASGUN,o $ cr PIPE, o $ cr PRISM] lasWidePulse
    , p [o LASGUN,o $ cr TRANSFORMER,o $ cr PRISM] (lasWide 2)

    , p [o $ cr TRANSFORMER,p 2 $ cr CAN] sparkGun
    , p [o SPARKGUN,p 2 $ cr PIPE] teslaGun

    , p [o $ cr TELEPORTMODULE,p 2 $ cr MICROCHIP] blinkGun
    , p [o BLINKER, p 2 $ cr MICROCHIP] unsafeBlinkGun

    , po [cr MAGNET,cr TIN] magShield

    , p [p 2 $ cr PIPE,o $ cr PLATE,o $ cr MOTOR] powerLegs

    , p [p 4 $ cr CAN] plateCraft
    , p [p 3 $ cr TIN] plateCraft
    , p [p 2 $ cr DRUM] plateCraft

    , p [p 2 $ cr PLATE] flatShield
    ] 
    ++ map (\i -> po [LASGUNWIDE i,cr TRANSFORMER,cr PRISM] $ lasWide (i+1)) [1..9]
    ++ map (\i -> po [LASGUNWIDE i,cr HARDWARE] $ lasFocus i) [1..10]
    ++ map (\i -> po [cr PIPE,BANGSTICK i] $ bangStick (i+1)) [1..8]
    ++ map (\i -> po [REVOLVERX i,cr CAN]  $ revolverX (i+1)) [1..5]
    ++ map (\i -> p [o (BANGCANEX i),p 2 $ cr PIPE] $ bangCaneX (i+1)) [1..5]
    ++ map (\i -> po [MINIGUNX i,BANGCANE] $ miniGunX (i+1)) [3..15]

    ++ [ po (_iyBase (_itType it):mtype) $ it & itType . iyModules . ix modtype .~ m
            | (modtype,is,ms) <- moduleCombinations
            , it <- is
            , (mtype,m)  <- ms
        ]
  where
    p = (,)
    po xs it = (map o xs,it)
    o = (1,)
    cr = CRAFT

moduleCombinations :: [( ModuleSlot, [Item], [([ItemBaseType],ItemModuleType)] )]
moduleCombinations =
    [   ( ModRifleMag
        ,   [repeater
            ,autoRifle
            ,burstRifle
            ,fastBurstRifle
            ]
        ,   [amod [cr DRUM,cr HARDWARE]  DRUMMAG
            ,amod [cr MOTOR,cr HARDWARE] BELTMAG
            ]
        )
    ,   ( ModAutoMag
        ,   [autoRifle
            ,autoPistol
            ,smg
            ]
        ,   [amod [cr MAGNET,cr HARDWARE] MAGNETMAG
            ]
        )
    ,   ( ModBullet
        ,   bulletWeapons
        ,   [amod [cr INCENDIARYMODULE] INCENDBUL
            ,amod [cr BOUNCEMODULE]     BOUNCEBUL
            ,amod [cr STATICMODULE]     STATICBUL
            ,amod [cr CONCUSSMODULE]    CONCUSBUL
            ]
        )
    ,   ( ModTarget
        , homingLaunchers ++ bulletWeapons
        ,   [amod [cr MICROCHIP,cr CREATURESENSOR]    TARGCR
            ,amod [cr MICROCHIP,cr PRISM]             TARGLAS
            ,amod [cr MICROCHIP,cr TIN]               TARGPOS
            ]
        )
    ,   ( ModBulletTrajectory
        ,   bulletWeapons
        ,   [amod [cr MAGNET,    cr MICROCHIP,cr HARDWARE]  MAGNETTRAJ
            ,amod [cr MICROCHIP, cr HARDWARE]               FLECHETRAJ
            ,amod [cr ANTIMATTER,cr HARDWARE]               BEZIERTRAJ
            ]
        )
    ,   ( ModDualBeam
        ,   [lasDual]
        ,   [amod [cr INCENDIARYMODULE] INCENDLAS
            ,amod [cr TRANSFORMER]      SPLITLAS
            ,amod [cr STATICMODULE]     STATICLAS
            ]
        )
    ,   ( ModTeleport
        ,   teleportableWeapons
        ,   [amod [cr TELEPORTMODULE,cr MICROCHIP] WEPTELE
            ]
        )
    ,   ( ModLauncherHoming
        ,   homingLaunchers
        ,   [ amod [cr MICROCHIP,cr TRANSMITTER] LAUNCHHOME
            ]
        )
    ,   ( ModBattery
        , batteryGuns
        ,   [amod [cr BATTERY] EXTRABATTERY
            ]
        )
    ]
  where
    amod = (,)
    cr = CRAFT

homingLaunchers :: [Item]
homingLaunchers = launcher : [launcherX i | i <- [2..10]]

batteryGuns :: [Item]
batteryGuns =
    [ teslaGun
    , sparkGun
    , lasGun
    , lasSway
    , lasSwing
    ] ++ 
    [ lasWide i | i <- [1..10]
    ] ++
    [ lasFocus i | i <- [1..10]]

teleportableWeapons :: [Item]
teleportableWeapons  = bulletWeapons ++ batteryGuns ++ homingLaunchers

bulletWeapons :: [Item]
bulletWeapons = [bangStick i | i <- [1..9] ]
    ++ [bangCaneX i | i <- [1..6] ]
    ++ [revolverX i | i <- [1..5] ]
    ++ [miniGunX  i | i <- [3..16] ]
    ++ [bangCane
    ,pistol
    ,autoPistol
    ,smg
    ,machinePistol
    ,revolver
    ,rifle
    ,repeater
    ,autoRifle
    ,burstRifle
    ,fastBurstRifle
    ,completeBurstRifle
    ,bangCone
    ,blunderbuss
    ,bigBlunderbuss
    ,biggerBlunderbuss
    ,biggestBlunderbuss
    ]
