mirror of
https://github.com/codeninjasllc/codecombat.git
synced 2025-02-17 08:50:58 -05:00
Give China server all free levels but hide paid levels (#3855)
* Give China server all free levels but hide paid levels * Don't prompt to buy gmes on free-only server on insufficient gems for item/hero purchases
This commit is contained in:
parent
2c2c052d5a
commit
8ec17265dc
8 changed files with 34 additions and 18 deletions
|
@ -220,9 +220,15 @@ module.exports = class User extends CocoModel
|
|||
return true if me.isAdmin()
|
||||
return true if me.hasSubscription()
|
||||
return false
|
||||
|
||||
|
||||
isOnPremiumServer: ->
|
||||
me.get('country') in ['china', 'brazil']
|
||||
return true if me.get('country') in ['brazil']
|
||||
return true if me.get('country') in ['china'] and me.isPremium()
|
||||
return false
|
||||
|
||||
isOnFreeOnlyServer: ->
|
||||
return true if me.get('country') in ['china'] and not me.isPremium()
|
||||
return false
|
||||
|
||||
sendVerificationCode: (code) ->
|
||||
$.ajax({
|
||||
|
|
|
@ -18,16 +18,18 @@ block content
|
|||
div.col-md-4
|
||||
#account-links
|
||||
a.btn.btn-lg.btn-primary(href="/account/settings", data-i18n="play.settings")
|
||||
div.col-md-4
|
||||
#account-links
|
||||
a.btn.btn-lg.btn-primary(href="/account/payments", data-i18n="account.payments")
|
||||
if !me.isOnFreeOnlyServer()
|
||||
div.col-md-4
|
||||
#account-links
|
||||
a.btn.btn-lg.btn-primary(href="/account/payments", data-i18n="account.payments")
|
||||
div.row.row-bot-buffer
|
||||
div.col-md-4
|
||||
#account-links
|
||||
a.btn.btn-lg.btn-primary(href="/account/subscription", data-i18n="account.subscription")
|
||||
div.col-md-4
|
||||
#account-links
|
||||
a.btn.btn-lg.btn-primary(href="/account/prepaid", data-i18n="account.prepaid_codes") Prepaid Codes
|
||||
if !me.isOnFreeOnlyServer()
|
||||
div.col-md-4
|
||||
#account-links
|
||||
a.btn.btn-lg.btn-primary(href="/account/subscription", data-i18n="account.subscription")
|
||||
div.col-md-4
|
||||
#account-links
|
||||
a.btn.btn-lg.btn-primary(href="/account/prepaid", data-i18n="account.prepaid_codes") Prepaid Codes
|
||||
div.col-md-4
|
||||
#account-links
|
||||
a.btn.btn-lg.btn-primary.logout-btn(href="/account", data-i18n="login.log_out")
|
||||
|
|
|
@ -158,7 +158,7 @@ if view.showAds()
|
|||
button.btn.items(data-toggle='coco-modal', data-target='play/modal/PlayItemsModal', data-i18n="[title]play.items")
|
||||
button.btn.heroes(data-toggle='coco-modal', data-target='play/modal/PlayHeroesModal', data-i18n="[title]play.heroes")
|
||||
button.btn.achievements(data-toggle='coco-modal', data-target='play/modal/PlayAchievementsModal', data-i18n="[title]play.achievements")
|
||||
if me.get('anonymous') === false || me.get('iosIdentifierForVendor') || isIPadApp
|
||||
if (me.get('anonymous') === false || me.get('iosIdentifierForVendor') || isIPadApp) && !me.isOnFreeOnlyServer()
|
||||
button.btn.gems(data-toggle='coco-modal', data-target='play/modal/BuyGemsModal', data-i18n="[title]play.buy_gems")
|
||||
if !me.get('anonymous', true)
|
||||
button.btn.account(data-toggle='coco-modal', data-target='play/modal/PlayAccountModal', data-i18n="[title]play.account")
|
||||
|
|
|
@ -176,6 +176,8 @@ module.exports = class CampaignView extends RootView
|
|||
if me.level() < 12 and @terrain is 'dungeon' and not @editorMode
|
||||
reject = if me.getFourthLevelGroup() is 'signs-and-portents' then 'forgetful-gemsmith' else 'signs-and-portents'
|
||||
context.levels = _.reject context.levels, slug: reject
|
||||
if me.isOnFreeOnlyServer
|
||||
context.levels = _.reject context.levels, 'requiresSubscription'
|
||||
@annotateLevel level for level in context.levels
|
||||
count = @countLevels context.levels
|
||||
context.levelsCompleted = count.completed
|
||||
|
@ -669,7 +671,7 @@ module.exports = class CampaignView extends RootView
|
|||
console.error "CampaignView hero update couldn't find hero slug for original:", hero
|
||||
|
||||
onClickPortalCampaign: (e) ->
|
||||
campaign = $(e.target).closest('.campaign, .beta-campaign')
|
||||
campaign = $(e.target).closest('.campaign, .beta-campaign')
|
||||
return if campaign.is('.locked') or campaign.is('.silhouette')
|
||||
campaignSlug = campaign.data('campaign-slug')
|
||||
Backbone.Mediator.publish 'router:navigate',
|
||||
|
|
|
@ -538,7 +538,7 @@ module.exports = class InventoryModal extends ModalView
|
|||
affordable = item.affordable
|
||||
if not affordable
|
||||
@playSound 'menu-button-click'
|
||||
@askToBuyGems button
|
||||
@askToBuyGems button unless me.isOnFreeOnlyServer()
|
||||
else if button.hasClass('confirm')
|
||||
@playSound 'menu-button-unlock-end'
|
||||
purchase = Purchase.makeFor(item)
|
||||
|
|
|
@ -236,7 +236,7 @@ module.exports = class PlayHeroesModal extends ModalView
|
|||
affordable = @visibleHero.get('gems') <= me.gems()
|
||||
if not affordable
|
||||
@playSound 'menu-button-click'
|
||||
@askToBuyGems button
|
||||
@askToBuyGems button unless me.isOnFreeOnlyServer()
|
||||
else if button.hasClass('confirm')
|
||||
@playSound 'menu-button-unlock-end'
|
||||
purchase = Purchase.makeFor(@visibleHero)
|
||||
|
|
|
@ -187,7 +187,7 @@ module.exports = class PlayItemsModal extends ModalView
|
|||
affordable = item.affordable
|
||||
if not affordable
|
||||
@playSound 'menu-button-click'
|
||||
@askToBuyGems button
|
||||
@askToBuyGems button unless me.isOnFreeOnlyServer()
|
||||
else if button.hasClass('confirm')
|
||||
@playSound 'menu-button-unlock-end'
|
||||
purchase = Purchase.makeFor(item)
|
||||
|
|
|
@ -302,14 +302,20 @@ UserSchema.methods.isPremium = ->
|
|||
return false
|
||||
|
||||
UserSchema.methods.isOnPremiumServer = ->
|
||||
@get('country') in ['china', 'brazil']
|
||||
return true if @get('country') in ['brazil']
|
||||
return true if @get('country') in ['china'] and @isPremium()
|
||||
return false
|
||||
|
||||
UserSchema.methods.isOnFreeOnlyServer = ->
|
||||
return true if @get('country') in ['china'] and not @isPremium()
|
||||
return false
|
||||
|
||||
UserSchema.methods.level = ->
|
||||
xp = @get('points') or 0
|
||||
a = 5
|
||||
b = c = 100
|
||||
if xp > 0 then Math.floor(a * Math.log((1 / b) * (xp + c))) + 1 else 1
|
||||
|
||||
|
||||
UserSchema.methods.isEnrolled = ->
|
||||
coursePrepaid = @get('coursePrepaid')
|
||||
return false unless coursePrepaid
|
||||
|
|
Loading…
Reference in a new issue