loot
This commit is contained in:
@ -1,7 +1,4 @@
|
||||
class AdminController < ApplicationController
|
||||
# echo "ya got butts?" | sha256
|
||||
PASSWORD = "50cf9308a2cd117a16f7c1f8eb2267fb87556066403b751f8fbf0af159bc9bac"
|
||||
|
||||
before_action :authenticate_admin, only: [:index, :set_alt, :clear_alt ]
|
||||
|
||||
def index
|
||||
@ -42,7 +39,7 @@ class AdminController < ApplicationController
|
||||
|
||||
def login_submit
|
||||
pw = params[:password]
|
||||
if pw == PASSWORD
|
||||
if pw == ENV["ADMINPW"]
|
||||
session[:user_id] = 1
|
||||
redirect_to admin_path, notice: "Logged in!"
|
||||
else
|
||||
|
@ -2,15 +2,16 @@ class BotController < ApplicationController
|
||||
skip_before_action :verify_authenticity_token
|
||||
before_action :authenticate
|
||||
|
||||
def players
|
||||
|
||||
def leaderboard
|
||||
players = Player.where(main_player_id: nil).order(purse: :desc)
|
||||
render json: players
|
||||
end
|
||||
|
||||
def summary
|
||||
|
||||
end
|
||||
|
||||
def player_name
|
||||
|
||||
def lords
|
||||
players = Player.where(main_player_id: nil).order(purse: :desc)
|
||||
lords = []
|
||||
lords << players.first
|
||||
lords << players.last
|
||||
render json: lords
|
||||
end
|
||||
end
|
||||
|
43
app/controllers/loot_controller.rb
Normal file
43
app/controllers/loot_controller.rb
Normal file
@ -0,0 +1,43 @@
|
||||
class LootController < ApplicationController
|
||||
skip_before_action :verify_authenticity_token, only: [ :create ]
|
||||
before_action :authenticate, only: [ :create ]
|
||||
|
||||
respond_to? :json
|
||||
|
||||
def create
|
||||
@loot = Loot.new(item_id: params[:item_id], item_name: params[:item_name], timestamp: params[:timestamp], roll_type: params[:roll_type])
|
||||
|
||||
player = Player.find_by(name: params[:player])
|
||||
if player.nil?
|
||||
player = Player.new(name: params[:player], wins: 0, losses: 0, purse: 0)
|
||||
player.save
|
||||
end
|
||||
@loot.player = player
|
||||
|
||||
if @loot.save
|
||||
render json: {}, status: :ok
|
||||
else
|
||||
render json: { error: "Unable to process input" }, status: :unprocessable_content
|
||||
end
|
||||
end
|
||||
|
||||
def index
|
||||
@players = Player.all.reject(&:alt?).map { |player| [
|
||||
player.name,
|
||||
player.get_loot_count_with_roll("mainspec"),
|
||||
player.get_loot_count_with_roll("minor"),
|
||||
player.get_loot_count_with_roll("offspec"),
|
||||
player.get_loot_count_with_roll("transmog"),
|
||||
]}.sort
|
||||
end
|
||||
|
||||
def list
|
||||
@loot = Loot.all.sort_by &:timestamp
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def already_reported_response
|
||||
render json: { error: "Already reported this loot" }, status: :already_reported
|
||||
end
|
||||
end
|
Reference in New Issue
Block a user